How should I execute Javascript files independently?
<p>Let's say I had an array of Javascript file names:</p>

<pre><code>["funScriptStuff.js", "jQuery.js", "dojo.js", "scriptyScript.js"]
</code></pre>

<p>how could I execute them independently of each other? </p>

<p>For example, let's suppose one script did some evil stuff like </p>

<pre><code>var undefined = true;
var window = "Windows 98";
</code></pre>

<p>and another script had code that relied on these global variables being unsabotaged</p>

<pre><code>if (a !== undefined) {
  window.open(url);
}
</code></pre>

<p>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?</p>

<p><strong>EDIT:</strong> 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.</p>
