I'm not sure what happened to your code, but here is how I would do it:
function loadOrdered(files, callback) { $.getScript(files.shift(), function() { files.length ? loadOrdered(files, callback) : callback(); }); }
change, more pleasant version:
function loadOrdered(files, callback) { $.getScript(files.shift(), files.length ? function(){loadOrdered(files, callback);} : callback ); }
or even better if you donβt need old browsers or implement Function.prototype.bind yourself (with support for binding arguments too, and not just this context):
function loadOrdered(files, callback) { $.getScript(files.shift(), files.length ? loadOrdered.bind(null, files, callback) : callback ); }
shesek
source share