I sometimes need to load my JS libraries like this so I always get the current version...
<script src="https://cdn.domain.com/file.js"></script>
However, my current issue, is I need to load this file in my Javascript code, not through HTML.
PseudoCode:
waitforload(getscript('https://cdn.domain.com/file.js'));
I need to load the file and then wait until loaded to proceed on to additional code that uses the library (file.js)
What is the best way to do this? I can't seem to find a simple and good solution.
Not a duplicate
As both solutions recommends using callbacks. I do not want to use a callback to execute code after it's run. I want the library to load, then move on to the next code to execute.
How do I include a JavaScript file in another JavaScript file?
Example:
waitforload(getscript('https://cdn.domain.com/file.js'));
el = new Helpers.Domain.fromFileJs();
el.something();
Vs.
waitforload(getscript('https://cdn.domain.com/file.js', 'mycode()'));
function my code()
el = new Helpers.Domain.fromFileJs();
el.something();
end
As to me, the first version easier to deal with as I am loading a module full of helpers classes and other code, and it's not just one item.