load dependent scripts sequentially

This commit is contained in:
mappu 2017-10-15 21:58:22 +13:00
parent 9669f2aa0b
commit 987c704730
2 changed files with 12 additions and 14 deletions

View File

@ -88,21 +88,19 @@ var contented = (function() {
}; };
var loadScripts = function(urls, onLoad) { var loadScripts = function(urls, onLoad) {
if (urls.length === 0) { // load sequentially
var i = 0;
var loadNext = function() {
if (i === urls.length) {
onLoad(); onLoad();
return; return;
} }
var totalLoaded = 0; var url = urls[i];
var cb = function() { i += 1;
totalLoaded += 1; loadScript(url, loadNext);
if (totalLoaded == urls.length) {
onLoad();
}
}; };
for (var i = 0; i < urls.length; ++i) { loadNext();
loadScript(urls[i], cb);
}
}; };
var formatBytes = function(bytes) { var formatBytes = function(bytes) {

File diff suppressed because one or more lines are too long