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) {
if (urls.length === 0) {
onLoad();
return;
}
var totalLoaded = 0;
var cb = function() {
totalLoaded += 1;
if (totalLoaded == urls.length) {
// load sequentially
var i = 0;
var loadNext = function() {
if (i === urls.length) {
onLoad();
return;
}
var url = urls[i];
i += 1;
loadScript(url, loadNext);
};
for (var i = 0; i < urls.length; ++i) {
loadScript(urls[i], cb);
}
loadNext();
};
var formatBytes = function(bytes) {

File diff suppressed because one or more lines are too long