Skip to content

Instantly share code, notes, and snippets.

@vseventer
Created November 19, 2011 14:53
Show Gist options
  • Save vseventer/1378913 to your computer and use it in GitHub Desktop.
Save vseventer/1378913 to your computer and use it in GitHub Desktop.
jQuery multiple parallel getScript
;(function($) {
'use strict';
/**
* Multiple parallel getScript
*
* @access public
* @param Array|String url (one or more URLs)
* @param callback fn (oncomplete, optional)
* @returns void
*/
var getScript = $.getScript;
$.getScript = function(url, fn) {
if(!$.isArray(url)) {//juggle type
url = [url];
}
$.when.apply(null, $.map(url, getScript)).done(function() {
fn && fn();
});
};
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment