Recommended way to "load" javascript file dependencies?
<p>I have a priorityQueue class that depends on a set of heap functions being loaded.
Currently they're in separate files, priorityQueue.js and fheap.js.
I would like to do</p>

<pre><code>&lt;script src="priorityQueue.js"&gt;&lt;/script&gt;
</code></pre>

<p>and have the fheap.js file automatically loaded (order doesn't matter). Furthermore, I'd like a method that cascades (ie dijkstra.js loads priorityQueue loads fheap).</p>

<p>Currently each file just loads its dependencies by injecting  elements at end of . Is there a better way to achieve the same result, and what should I watch out for with the current method?</p>
