Remove all script elements using JS
<p>I am trying to remove all script elements from a HTML page. But for some reason, I can only remove about half of them using the below:</p>

<pre><code>function t(){

   var r = document.getElementsByTagName('script');

    for (var i = 0; i &lt; r.length; i++) {

        if(r[i].getAttribute('id') != 'a'){

            r[i].parentNode.removeChild(r[i]);

        }

    }

}
</code></pre>

<p>I have that if condition so that I don't remove the executing script.</p>

<p>I am essentially trying to create a <em>dynamic</em> Javascript dis-abler for my selenium tests.</p>
