load dependent scripts sequentially
This commit is contained in:
parent
9669f2aa0b
commit
987c704730
@ -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
Loading…
Reference in New Issue
Block a user