How can I dynamically unload a javascript file?

This really sounds like you need to reevaluate your design. Either you need to drop ajax, or you need to not have collisions in you method names.

You can review this link: http://www.javascriptkit.com/javatutors/loadjavascriptcss2.shtml

Which gives information on how to remove the javascript from the DOM. However, modern browsers will leave the code in memory on the browser.


No, you can't do that. Once a block of JavaScript gets loaded in the browser and executed, it gets stored in browser memory under the scope of the respective window. There is absolutely no way to unload it (without page refresh/window close).


you can just namespace your code.. that way you prevent collisions

var MyJavaScriptCode = {};

MyJavaScriptCode.bla = function () {};