Skip to content

Instantly share code, notes, and snippets.

@Fardinak
Created December 18, 2013 15:29
Show Gist options
  • Save Fardinak/8024268 to your computer and use it in GitHub Desktop.
Save Fardinak/8024268 to your computer and use it in GitHub Desktop.
Simple script to load a stack of javascript requisites. Depends on jQuery's getScript.
function loadStack(stack, cb) {
if($.isArray(stack)) {
if(stack.length === 0) return cb();
// TODO: implement the getScript method to make it standalone
$.getScript(stack.shift() + '.js', loadStack.bind(this, stack, cb));
}
}
loadStack([
// Modules
'modules/base',
'modules/jalali',
'modules/raphael',
// Application
'app/init',
'app/services'
], function() {
console.log('Initiated.');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment