feat: Remove script element immediately in injectScript#1761
Merged
aklinker1 merged 2 commits intowxt-dev:mainfrom Dec 16, 2025
Merged
feat: Remove script element immediately in injectScript#1761aklinker1 merged 2 commits intowxt-dev:mainfrom
aklinker1 merged 2 commits intowxt-dev:mainfrom
Conversation
✅ Deploy Preview for creative-fairy-df92c4 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This was referenced Jun 19, 2025
aklinker1
approved these changes
Aug 3, 2025
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.
300b769 to
41833c6
Compare
Contributor
Author
Unless I misunderstand which PR you meant by the one you closed, it was one of the three PRs for the same issue but not the one posted by me. |
Timeraa
approved these changes
Aug 3, 2025
@wxt-dev/analytics
@wxt-dev/auto-icons
@wxt-dev/browser
@wxt-dev/i18n
@wxt-dev/module-react
@wxt-dev/module-solid
@wxt-dev/module-svelte
@wxt-dev/module-vue
@wxt-dev/runner
@wxt-dev/storage
@wxt-dev/unocss
@wxt-dev/webextension-polyfill
wxt
commit: |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1761 +/- ##
==========================================
- Coverage 76.62% 76.42% -0.20%
==========================================
Files 113 113
Lines 3025 3025
Branches 686 686
==========================================
- Hits 2318 2312 -6
- Misses 624 629 +5
- Partials 83 84 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
|
Thanks for helping make WXT better! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
The patch series in which each PR builds on top of the previous one: #1761 (you are here), #1762, #1763, #1838, #1765.
In case some of the changes are rejected, I will rebase the subsequent PRs on top of main.
Overview
I am trying to minimize any chance of my extension leaving something in the DOM or the window object etc.
A script which fails to load would be left in the DOM. Rather than adding an
onerrorhandler, it seems that the script element can just be removed immediately after being added.Everything seems to work: the script is executed;
onload,onerrorhandlers do the right thing;document.currentScriptinvoked by the script returns the detached script element.Manual Testing
Just using
injectScriptnormally should suffice. I am working on an extension which usesinjectScript. It seems to work fine with this change.Related Issue
N/A