Let's say I had an array of Javascript file names:
["funScriptStuff.js", "jQuery.js", "dojo.js", "scriptyScript.js"]
how could I execute them independently of each other?
For example, let's suppose one script did some evil stuff like
var undefined = true;
var window = "Windows 98";
and another script had code that relied on these global variables being unsabotaged
if (a !== undefined) {
window.open(url);
}
if the first script ran first, it would ruin everything in the second one. Without changing anything in these script files, how can I run them independently of each other to prevent them from messing each other up?
EDIT: I am not asking what Javascript patterns to use to prevent namespace collisions, like wrapping my code in a big closure and so forth. I know about those. I'm trying to create an environment where you can run arbitrary scripts that I have no control over without them stepping on each other's toes.