Is there a way to use JavaScript to "remove" a script tag from the DOM BEFORE the script tag gets a chance to execute.
3 Answers
No, javascript can only manipulate parts of the DOM that are loaded already.
1 Comment
wajiw
Though, if you had a switch/boolean on those script tags that had to be set by the initial javascript call, that could work. You just won't be able to remove the tags until after they're loaded.
You can do that in Opera with user JavaScript. Here's and example from my UserJS:
window.opera.addEventListener('BeforeScript',function (e)
{
// src filter
var patt1=/collapse|sibnet|upload|progress|krscat|anet|textarea/gi;
// text filter
var patt2=/saturn-plus|tracker_krs|krasland/gi;
if (e.element.src.match(patt1)!=null || e.element.text.match(patt2)!=null) e.element.parentNode.removeChild(e.element);
},false);