jQuery offers the getScript( file, callback) function that loads a script file, interprets it, and then calles a callback() - function.
If multiple files need to be loaded before executing the callback,one might think of a solution like this one:
function loadOrdered(files, callback) {
$.getScript(files.shift(), files.length
? function(){loadOrdered(files, callback);}
: callback
);
}
However, this forces the files to be loaded in a very specific order, which means that the browser has to wait for the server to respond before loading the next script. This probably causes an unnecessary delay.
How can I achieve the same effect as with the above code, without forcing the browser to load the scrips sequentially?