javascript: add script that will be evaluated before body scripts?
<p>I have a script foo.js that is included in <code>&lt;head&gt;</code>. Inside body I have an inline script. Inside it, I want to add to the document another script for bar.js that will be loaded and evaluated before the inline script.</p>

<pre><code>&lt;html&gt;
  &lt;head&gt;
    &lt;script src="foo.js" type="text/javascript"/&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;script type="text/javascript"&gt;
      bar()
    &lt;/script&gt;
  &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>In foo.js I want to add a script pointing to bar.js</p>

<p>bar.js:</p>

<pre><code>function bar() {
  alert('hi');
} 
</code></pre>

<p>What should be the code of foo.js?</p>

<p>NOTE: I know I can use onload in this trivial example. But in my real case, bar.js contains a function that is called several times and I want to be able to inline these calls in the right sections of the page (for code locality)</p>
