I have 2 javascript files that cannot co-exist. If a user click on one button, it loads one js file. If a user clicks another button, it loads the other file. But the last one needs to be unloaded first
Here is generally what I have:
//pseudocode
if user clicks button one
loadScript(one);
if user clicks button two
loadScript(two);
//not psuedocode
function loadScript(name)
{
var javascriptLoc = name + "/config.js";
//Unload any scripts that were previously loaded by requirejs
require.undef(); //HELP
//once config.js is loaded by requirejs...
require([javascriptLoc], function(util) {
//do stuff
});
}
Is there a way to unload one/config.js and load two/config.js instead? Then when a user clicks on "one", it would load one/config.js instead of two/config.js?
Other ways to word the question:
what do I do in requirejs when I have exclusive dependancies...
how do I deal with conflict resolution in requirejs...
how do I reset or unload scripts previously loaded by requirejs...