Skip to content Skip to sidebar Skip to footer

Can I Remove A Javascript From The Dom With Another Javascript?

I have this situation where I have to delete a script tag from the DOM with only the possibility of using another script for this. I know this isn't a good way of working, but it's

Solution 1:

Is it possible to delete a script tag from the DOM by using another script for this.

Yes, you can remove <script> nodes from the DOM as you can modify any other nodes as well. You even can write a script that removes it's own element.

I think that when I delete this script you will still be able to use the functions inside.

That is correct. When the script has already been executed, the modifications it made to the environment will remain. You can't undo them other than by unloading the page (or explicitly overwriting them - if possible).

Post a Comment for "Can I Remove A Javascript From The Dom With Another Javascript?"