I want to write a basic script that can function as a dependency manager like RequireJS (but not as complex).
Ideally, like RequireJS, I'd like to be able to call a function, and give the function an array of scripts to load and a callback to call when the scripts are finished loading. I'm thinking of something like the following:
myRequireFunc(['scriptA', 'scriptB', 'scriptC'], function () {
// Callback code here
});
Following the following SO thread, I was able to make some progress with dynamically loading scripts and then calling a callback when they're all loaded, but the issue I'm having now is what to do when scriptA, scriptB or scriptC has a dependency of its own:
Dynamically load external javascript file, and wait for it to load - without using JQuery
Can anyone please offer some advice/direction on how to handle dependencies so that a call to myRequireFunc
will not call the callback until all scripts and all dependencies of those scripts have loaded?