On 2011-08-03 15:49, UI Architect wrote:
> Is there a way to unload an already loaded script? Let's say, I put a
> <script> tag with src to an external JS file. It gets loaded and
> executed in the browser. After this point, is there any way to unload
> (also from browser memory) that script?
Not reliably. If you know exactly what the script did, you can try to
reverse its effects, but that's not always possible. For example, the
included script could do something like -
(function () {
function butIRepeatMyself () {
alert("Am I annoying you?");
}
window.setInterval(butIRepeatMyself, 5000);
})();
- and there's nothing you can do to stop it (short of navigating away).
If I wanted to remove a script completely, I'd probably let the page
reload without including that script. I don't really see the use case
for that, to be honest.
> Removing the script tag from the DOM is not going to help here for
> sure. Any clues?
Not really, but I've been wondering what it is that you're trying to do.
An URL-blocker that runs inside the document, and now removing scripts
which have already been executed... both of these sound like you're
trying to implement some security feature from inside the document which
should better be handled from outside.
--
stefan
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]