I have a script abc.js, which has an event handler for a button as follows:
$("button").on("click", function(e){
$("script[src='abc.js']").remove();
});
what happens when the remove on the executing script is called? Will the script be unloaded, or will it stop executing? And what happens when the script is removed from other script file?
Will the script be unloaded, or will it stop executing?Nope, since script tag is just a way to load the script and JS engine doesn't check the presence of script tag before executing a statement.$("<script src='abc.js'></script>").remove();does not remove an executing script tag, it creates a new<script>tag with theabc.jsassrc, but this tag was never added to the DOM, soremove()does not have an effect anyway.