优化加载js的代码

This commit is contained in:
CounterFire2023 2023-09-22 13:17:46 +08:00
parent eb1a7c4414
commit 39af283b07

View File

@ -50,10 +50,9 @@ button{
return new Promise((resolve, reject) => {
let src = sub[0];
console.log(`>> begin load script: ${src}`);
var s = document.createElement('script');
let s = document.createElement('script');
s.async = true;
if (sub[1] == 1)s.type = 'module';
// s.src = src + (src.indexOf("?") == -1 ? "?" : "&") + "t=" + Date.now();
s.src =src;
s.addEventListener('load', function () {
console.log(`<< finish load script: ${src}`);
@ -81,8 +80,7 @@ button{
list[loaded][0] = list[loaded][0] + (list[loaded][0].indexOf("?") == -1 ? "?" : "&") + "t=" + Date.now();
}
loadSingleScript(list[loaded]).then(() => {
loaded++;
if (loaded >= list.length) {
if (++loaded >= list.length) {
resolve && resolve();
} else {
return loadNext();