2

Is there a way to use JavaScript to "remove" a script tag from the DOM BEFORE the script tag gets a chance to execute.

0

3 Answers 3

4

No, javascript can only manipulate parts of the DOM that are loaded already.

Sign up to request clarification or add additional context in comments.

1 Comment

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.
1

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);

Comments

0

why can't you remove the tag serverside ? perhaps there is an outbound filter you could use with apache to remove the tags?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.