Skip to content

Commit cff0d8f

Browse files
authoredMay 5, 2022
Merge pull request #181 from kaliber5/defer
Load scripts in parallel instead of sequentially
2 parents 86eb9df + 9876d37 commit cff0d8f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed
 

‎vendor/embed.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
if (script.content) {
2222
scriptTag.textContent = script.content;
2323
}
24+
scriptTag.defer = true;
25+
scriptTag.async = false;
26+
2427
head.appendChild(scriptTag);
2528
if (!hasSrc) {
2629
resolve();
@@ -29,9 +32,9 @@
2932
}
3033

3134
async function injectScripts(scripts, head, host) {
32-
for (let script of scripts) {
33-
await injectScript(script, head, host);
34-
}
35+
await Promise.all(
36+
scripts.map((script) => injectScript(script, head, host))
37+
);
3538
}
3639

3740
function injectLinks(links, head, host) {

0 commit comments

Comments
 (0)
Please sign in to comment.