parent
b0a03d53fc
commit
be4fd17113
|
@ -69,6 +69,7 @@
|
||||||
|
|
||||||
//#region for our extension pages
|
//#region for our extension pages
|
||||||
|
|
||||||
|
const reqPromise = {};
|
||||||
window.require = async function require(urls, cb) {
|
window.require = async function require(urls, cb) {
|
||||||
const promises = [];
|
const promises = [];
|
||||||
const all = [];
|
const all = [];
|
||||||
|
@ -83,13 +84,14 @@
|
||||||
if (!el) {
|
if (!el) {
|
||||||
el = document.createElement(tag);
|
el = document.createElement(tag);
|
||||||
toLoad.push(el);
|
toLoad.push(el);
|
||||||
promises.push(new Promise((resolve, reject) => {
|
reqPromise[url] = new Promise((resolve, reject) => {
|
||||||
el.onload = resolve;
|
el.onload = resolve;
|
||||||
el.onerror = reject;
|
el.onerror = reject;
|
||||||
el[attr] = url;
|
el[attr] = url;
|
||||||
if (isCss) el.rel = 'stylesheet';
|
if (isCss) el.rel = 'stylesheet';
|
||||||
}).catch(console.warn));
|
}).catch(console.warn);
|
||||||
}
|
}
|
||||||
|
promises.push(reqPromise[url]);
|
||||||
all.push(el);
|
all.push(el);
|
||||||
}
|
}
|
||||||
if (toLoad.length) document.head.append(...toLoad);
|
if (toLoad.length) document.head.append(...toLoad);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user