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
<script src="priorityQueue.js"></script>
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).
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?