JavaScript - How to load external script NON-asynchronously?
<p>I'm looking for code that allows me to use JavaScript to load another JavaScript file NON-asynchronously. I tried this:</p>

<pre><code>var script=document.createElement('script');
script.setAttribute("type","text/javascript");
script.setAttribute("src", "jquery.min.js");
document.getElementsByTagName("head")[0].appendChild(script);

$("div.whatever").css("color","red");
</code></pre>

<p>But that doesn't work. It inserts the script node okay, but it continues to run the rest of the script before jQuery loads. This ends up failing because the jQuery code tries to run when <code>$</code> isn't defined by jQuery yet.</p>

<p>Is there a way to load that script non-async using native JS?</p>
