On demand JavaScript loader that doesn't block.
- LABjs performance script loader ( the best!).
- Custom wrapper and config object to make life easier.
Include LAB.min.js and delphic.inject.js in that order on your page.
Config example:
var LABconfig = {
paths: {
'jquery' : 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js',
'myCss' : '/css/plugins/my.css',
'jquery.easing' : 'http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js'
},
shortcuts: {
'jqueryWithEasing' : ['jquery','jquery.easing']
}
}- Use
pathsto declare where your JavaScript or CSS files should be loaded from. Can be any url, absolute or relative. - Use
shortcutsto declare dependecies with an array ofpaths. Order of array elements determines the order of load.
When you need to use a JavaScript file, you use the defined path or shortcut variable from the config.
To use a path, pass an array of path variables:
DELPHIC.inject(['jquery', 'jquery.easing'],function(){
//Both jquery and jquery.easing have finished loading
})Or, pass a shorcut variable as a string:
DELPHIC.inject('jqueryWithEasing',function(){
//Both jquery and jquery.easing have finished loading
})Those two function calls are equivalent.