Can an external Javascript file be called and executed depending on a conditional?
<p>I know that I can run an external Javascript file from within HTML with the following syntax:</p>

<pre><code>&lt;script type="text/javascript"
src="http://somesite.com/location/of/javascript.js"&gt;
&lt;/script&gt;
</code></pre>

<p>This will result in <code>http://somesite.com/location/of/javascript.js</code> being run the moment the browser reads that line of the HTML.</p>

<p>But is there a way I can run an external Javascript file from within Javascript? Something like:</p>

<pre><code>if (x == 1)
{
 run this! -&gt; http://somesite.com/location/of/javascript.js;
}
</code></pre>

<p>Obviously that's not valid code. But I can't find any example of what might be the right way to do this (if it exists), because all the help text I find with Google searches tell me how to run Javascript from within HTML</p>

<p>I know that I can include a Javascript file and then call functions within it. However, in this situation, I do not have any control over <code>http://somesite.com/location/of/javascript.js</code>, and it is designed to execute the moment it is called. I can't change how it works, so I need to figure out how to call it at the right time in the right way.</p>

<p>Is there a way I can get it to be called and executed immediately depending on a conditional statement?</p>
