0

On certain sites, script tags are loaded in the head, some of which are async script tags. Using my own javascript to delete these tags doesn't work but manually deleting them from the site works (they don't execute if I do that). How can I delete all javascript tags in the head even if they are in the process of asynchronously executing code?

1 Answers1

0

script tags in sites you visit get executed despite you deleting them from the DOM. Edits on the DOM from your element inspector does not affect them. You can insert JS and HTML in webpages but it only executes on your machine. See this answer: https://stackoverflow.com/a/10076783/10533611

subparry
  • 333
  • 2
  • 9
  • is there any way I could prevent them from executing? I'm writing a chrome extension and I'm trying to stop the script before it loads. – Derek Wu Nov 19 '22 at 02:51
  • you can make use of the defer in the script tag it will download the script but will not execute it immediately after parsing the html it will start executing the downloaded script – Sai Sundeep Nov 21 '22 at 10:17