Programmatically remove the link <script src = "/unwanted.js" ../>
I have partial control over a web page where I can enter snippets of code in different places, but I canβt delete any existing code.
There is a script link halfway through the page
<script src="/unwanted.js" type="text/javascript"></script> but I do not want to load the script. I cannot access the unwanted.js file. Is there anyway I can use javascript running on this refernce so that the unwanted.js file does not load?
Change To respond to comments by asking what and why:
I am setting up a Stack Exchange site, and the WMD * js file is uploaded to half the page. SE allows you to embed HTML in various parts of the page - so you can have your own custom header and footer, etc. I want to override the standard WMD code with my own version. I can get around this by simply loading javascript after loading the original WMD script and replacing it with my own functions - but it would be nice to not have such a large piece of JS load unnecessarily.
* WMD = down label editor used here in SO and on SE sites.
Please tell us what you can and cannot do, and (preferably, this sounds exciting).
If you can, try pasting <!-- before including the script and --> to comment on this.
Alternatively, view the script file and see if there is a way you could break it or hide its consequences. (this will entirely depend on the script itself, if you want more specific recommendations, write more detailed information or, preferably, a script.
You can remove the script from the DOM after calling it using something simple, for example:
s = document.getElementById ("my_script"); s.parentNode.removeChild(s); This will stop all script functions, but will not remove it from the user's cache. However, as you wish, it cannot be used.