use loadScriptsParallel

This commit is contained in:
rolux 2012-05-26 00:20:52 +02:00
parent 5086c5da90
commit 093af4ee35

View file

@ -58,24 +58,25 @@ window.Ox = {
}
function loadScripts(scripts, callback) {
loadScriptsOrdered(scripts[0], function() {
loadScriptsUnordered(scripts[1], function() {
loadScriptsUnordered(scripts[2], callback);
loadScriptsParallel(scripts[0], function() {
loadScriptsParallel(scripts[1], function() {
loadScriptsParallel(scripts[2], callback);
});
});
}
function loadScriptsOrdered(scripts, callback) {
// fixme: unused
function loadScriptsSerial(scripts, callback) {
loadScript(scripts.shift(), function() {
if (scripts.length) {
loadScriptsOrdered(scripts, callback);
loadScriptsSerial(scripts, callback);
} else {
callback();
}
});
}
function loadScriptsUnordered(scripts, callback) {
function loadScriptsParallel(scripts, callback) {
var counter = 0, i, length = scripts.length;
for (i = 0; i < length; i++) {
loadScript(scripts[i], function() {