Skip to content

Commit 300b769

Browse files
committed
feat: Remove script element immediately in injectScript
Everything seems to work: the script is executed; onload, onerror handlers do the right thing; document.currentScript invoked by the script returns the detached script element.
1 parent 7c783fe commit 300b769

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/wxt/src/utils/inject-script.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ export async function injectScript(
3232
script.src = url;
3333
}
3434

35+
(document.head ?? document.documentElement).append(script);
36+
3537
if (!options?.keepInDom) {
36-
script.onload = () => script.remove();
38+
script.remove();
3739
}
38-
39-
(document.head ?? document.documentElement).append(script);
4040
}
4141

4242
export interface InjectScriptOptions {

0 commit comments

Comments
 (0)