Skip to content

Commit

Permalink
Write async script tags in initial page render (#21)
Browse files Browse the repository at this point in the history
`<script async>` tags can be downloaded in parallel, speeding up page initialization.

I tested that Webpack and Derby load fine regardless of what order scripts finish downloading in. It works even when the Webpack runtime script finishes its download last.
  • Loading branch information
ericyhwang authored May 17, 2023
1 parent 2865f3a commit 85f6ce6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function pluginForAppInstance(app) {
}
const scriptTags = assets.map(assetUrlPath => {
const scriptUrl = scriptBaseUrl + assetUrlPath;
return `<script ${scriptCrossOrigin ? 'crossorigin ' : ''}src="${scriptUrl}" type="text/javascript"></script>`
return `<script async ${scriptCrossOrigin ? 'crossorigin ' : ''}src="${scriptUrl}" type="text/javascript"></script>`
}).join('\n');
page.res.write(scriptTags);
});
Expand Down

0 comments on commit 85f6ce6

Please sign in to comment.