Skip to content

Instantly share code, notes, and snippets.

@rwaldron
Created May 18, 2011 00:56
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save rwaldron/977792 to your computer and use it in GitHub Desktop.
(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