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) {
|
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
Loading…
Reference in New Issue
Block a user