Skip to content

naden/include.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

include.js

Advanced include implementation for javascript files.

Add #async to any filename to enable asynchronous loading for that file.

Include a single file

include('test1.js');

include(['test1.js']);

Include a single file with async loading

include('test1.js#async');

Include a single file and execute a callback function after it's loaded

include('test1.js', function() {
 console.log('test1.js loaded');
});

include([
 [ 'test1.js', function() {
  console.log('test1.js loaded');
 }]
]);

Include two files

include('test1.js', 'test2.js');

include(['test1.js', 'test2.js']);

Include two files and execute a callback function after they're loaded

include('test1.js', 'test2.js', function() {
 console.log('test1.js and test2.js are loaded');
});

include(['test1.js', 'test2.js'], function() {
 console.log('init');
});

Include two files and execute a callback function per file

include([
 ['test1.js', function() {
  console.log('init1');
 }],
 ['test2.js', function() {
  console.log('init2');
 }]
]);

For a more detailed explanation have a look at this blogpost Javascript include.

About

Include with javascript.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published