Skip to content

Commit 50773c7

Browse files
authored
Remove async attribute from module script tag. (#5870)
Fixes #5869. Module scripts are deferred by default per HTML spec section 4.12.1 (prepare a script algorithm): parser-inserted type=module scripts without async go into the "list of scripts that will execute when the document has finished parsing" (executed in section 13.2.7 "The end"). Adding async makes the script execute as soon as it downloads, which can happen before DOM parsing completes, breaking document.getElementById and similar DOM access in the main bundle.
1 parent f0c4c03 commit 50773c7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

scripts/lib/esbuild-plugins.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export function generateHtmlPlugin(options) {
126126
const headTags = [];
127127

128128
headTags.push(
129-
`<script src="${convertPath(mainBundlePath)}" type="module" async></script>`
129+
`<script src="${convertPath(mainBundlePath)}" type="module"></script>`
130130
);
131131

132132
if (mainBundle.cssBundle) {

0 commit comments

Comments
 (0)