Set base url
jQuery.use.base = ‘http://example.com’;
Use a combine file as get args
jQuery.use.combine = true;
Setup the modules
jQuery.use.modules = {
‘test1’ : { ‘path’: ‘assets/scripts/test1.js’ },
‘test2’ : { ‘path’: ‘assets/scripts/test2.js’, ‘require’: ‘test1’ },
‘test3’ : { ‘path’: ‘assets/scripts/test3.js’, ‘require’: [‘test1’, ‘test2’] },
‘test4’ : { ‘path’: ‘assets/scripts/test4.js’ },
‘test5’ : { ‘path’: ‘assets/scripts/test5.js’, ‘require’: [‘test4’] }
};
Get the required files on the page
<script type="text/javascript" src="/deoxy?target=http%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fjquery%2F1.3.2%2Fjquery.min.js"></script>
<script type="text/javascript" src="/deoxy?target=http%3A%2F%2Fgithub.com%2Fm64253%2FjQuery-use%2Fraw%2Fmaster%2Fjquery.use.js"></script>
This should only load the “test1”
jQuery.use('test1', function($){
console.log('LOADED: "test1"');
});
This should only load the test2 module, as the test1 module should already be loaded
jQuery.use('test2', function($){
console.log('LOADED: "test2"');
});
This should fire off as soon the earlier test2 use is loaded
jQuery.use('test2', function($){
console.log('LOADED: "test2"');
});
This should only load the test3 module, as test1 , test2 modules should already be loaded
jQuery.use('test3', function($){
console.log('LOADED: "test3"');
});
This should only load both the the test4 and test5 module, test5 requires test4
jQuery.use('test5', function($){
console.log('LOADED: "test5"');
});
This should fire off as soon as the earlier test3 and test5 are done
jQuery.use(['test3', 'test5'], function($){
console.log('LOADED: "test3, test5"');
});
This should fire off directly , uses no modules
jQuery.use(function($){
console.log('LOADED: "none"');
});