Skip to content

Commit

Permalink
Merge pull request simonihmig#181 from kaliber5/defer
Browse files Browse the repository at this point in the history
Load scripts in parallel instead of sequentially
  • Loading branch information
simonihmig authored May 5, 2022
2 parents 86eb9df + 9876d37 commit cff0d8f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions vendor/embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
if (script.content) {
scriptTag.textContent = script.content;
}
scriptTag.defer = true;
scriptTag.async = false;

head.appendChild(scriptTag);
if (!hasSrc) {
resolve();
Expand All @@ -29,9 +32,9 @@
}

async function injectScripts(scripts, head, host) {
for (let script of scripts) {
await injectScript(script, head, host);
}
await Promise.all(
scripts.map((script) => injectScript(script, head, host))
);
}

function injectLinks(links, head, host) {
Expand Down

0 comments on commit cff0d8f

Please sign in to comment.