Import javascript file in javascript function
<blockquote>
  <p><strong>Possible Duplicates:</strong><br>
  <a href="http://stackoverflow.com/questions/3991492/include-a-javascript-file-in-a-javascript-file">Include a javascript file in a javascript file</a><br>
  <a href="http://stackoverflow.com/questions/950087/include-javascript-file-inside-javascript-file">Include JavaScript file inside JavaScript file?</a>  </p>
</blockquote>



<p>What is the best way to import javascript file (file.js) in javascript function().</p>

<p>For example what is the best way to replace the todo statement:</p>

<pre><code>function doSomething() {
   if (xy.doSomething == undefined) {
      // todo: load 'oldVersionPatch.js'
   }

   ...
}
</code></pre>

<p>Possibly the best solution is to create script element and add it into html page.
My questions are:</p>

<ul>
<li>is it better to add/append it into head, or body (what will load when)?</li>
<li>is it better to use javascript or jquery (what is more cross-browser compatible)?</li>
</ul>
