Created
November 19, 2011 14:53
-
-
Save vseventer/1378913 to your computer and use it in GitHub Desktop.
jQuery multiple parallel getScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(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