How would i have to change this example
$.when(
$.getScript( "/mypath/myscript1.js" ),
$.getScript( "/mypath/myscript2.js" ),
$.getScript( "/mypath/myscript3.js" ),
$.Deferred(function( deferred ){
$( deferred.resolve );
})
).done(function() {
//place your code here, the scripts are all loaded
});
when i don't know the exact number of scripts to load and use an array of URLs instead?
var urls = [
'/url/to/script1.js',
'/url/to/script2.js',
'/url/to/script3.js',
'/url/to/script4.js'
];
As the above example is a function call with arguments I cannot utilize a loop like $.each()
, can I? Also, I know about Function.apply
, but don't know how to adapt from passing an array of simple arguments to a function to passing an array of function calls to a function.