Skip to content

Conversation

@ion1
Copy link
Contributor

@ion1 ion1 commented Jun 19, 2025

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 onerror handler, it seems that the script element can just be removed immediately after being added.

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.

Manual Testing

Just using injectScript normally should suffice. I am working on an extension which uses injectScript. It seems to work fine with this change.

Related Issue

N/A

@ion1 ion1 requested review from Timeraa and aklinker1 as code owners June 19, 2025 13:23
@netlify
Copy link

netlify bot commented Jun 19, 2025

Deploy Preview for creative-fairy-df92c4 ready!

Name Link
🔨 Latest commit d5f9ac6
🔍 Latest deploy log https://app.netlify.com/projects/creative-fairy-df92c4/deploys/6941d1a397278700084bbe11
😎 Deploy Preview https://deploy-preview-1761--creative-fairy-df92c4.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Member

@aklinker1 aklinker1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, OK nice. If it works, it works! I just noticed your series of PRs... Might re-open the one I closed.

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.
@ion1 ion1 force-pushed the inject-script-remove-script-element branch from 300b769 to 41833c6 Compare August 3, 2025 14:24
@ion1
Copy link
Contributor Author

ion1 commented Aug 3, 2025

Huh, OK nice. If it works, it works! I just noticed your series of PRs... Might re-open the one I closed.

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.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 16, 2025

Open in StackBlitz

@wxt-dev/analytics

npm i https://pkg.pr.new/@wxt-dev/analytics@1761

@wxt-dev/auto-icons

npm i https://pkg.pr.new/@wxt-dev/auto-icons@1761

@wxt-dev/browser

npm i https://pkg.pr.new/@wxt-dev/browser@1761

@wxt-dev/i18n

npm i https://pkg.pr.new/@wxt-dev/i18n@1761

@wxt-dev/module-react

npm i https://pkg.pr.new/@wxt-dev/module-react@1761

@wxt-dev/module-solid

npm i https://pkg.pr.new/@wxt-dev/module-solid@1761

@wxt-dev/module-svelte

npm i https://pkg.pr.new/@wxt-dev/module-svelte@1761

@wxt-dev/module-vue

npm i https://pkg.pr.new/@wxt-dev/module-vue@1761

@wxt-dev/runner

npm i https://pkg.pr.new/@wxt-dev/runner@1761

@wxt-dev/storage

npm i https://pkg.pr.new/@wxt-dev/storage@1761

@wxt-dev/unocss

npm i https://pkg.pr.new/@wxt-dev/unocss@1761

@wxt-dev/webextension-polyfill

npm i https://pkg.pr.new/@wxt-dev/webextension-polyfill@1761

wxt

npm i https://pkg.pr.new/wxt@1761

commit: d5f9ac6

@codecov
Copy link

codecov bot commented Dec 16, 2025

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.42%. Comparing base (0404637) to head (d5f9ac6).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
packages/wxt/src/utils/inject-script.ts 0.00% 1 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aklinker1 aklinker1 merged commit 938c25c into wxt-dev:main Dec 16, 2025
18 checks passed
@github-actions
Copy link
Contributor

Thanks for helping make WXT better!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants