Skip to content

feat: Remove script element immediately in injectScript #1761

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ion1
Copy link

@ion1 ion1 commented Jun 19, 2025

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

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 requested review from aklinker1 and Timeraa as code owners June 19, 2025 13:23
Copy link

netlify bot commented Jun 19, 2025

Deploy Preview for creative-fairy-df92c4 ready!

Name Link
🔨 Latest commit 300b769
🔍 Latest deploy log https://app.netlify.com/projects/creative-fairy-df92c4/deploys/68540f36d05a530008a5b5e6
😎 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.

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.

1 participant