Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(function( jQuery ) {
var getScript = jQuery.getScript;
jQuery.getScript = function( resources, callback ) {
var // reference declaration & localization
length = resources.length,
handler = function() { counter++; },
deferreds = [],
counter = 0,
idx = 0;
for ( ; idx < length; idx++ ) {
deferreds.push(
getScript( resources[ idx ], handler )
);
}
jQuery.when.apply( null, deferreds ).then(function() {
callback && callback();
});
};
})( jQuery );
var deps = [ "http://documentcloud.github.com/backbone/backbone-min.js",
"http://documentcloud.github.com/underscore/underscore-min.js" ];
jQuery.getScript( deps, function( jqXhr ) {
console.log( jqXhr );
console.log( [ _, Backbone ] );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.