I want to remove a script element and replace it with a different one.
Lets say that you
<html>
<head>
<script src="default.js">
</head>
What I want to do is remove default.js and replace it with new.js on the click of a button. I know you can create a script like this:
var new_scr=document.createElement('script');
new_scr.src="new.js";
document.getElementsByTagName('head')[0].appendChild(new_scr);
you can set the id for script tag and change the content based on the id instead of replacing it with new one.
or following might be useful code block for you.