Instead of messing up my HTML file, I would like to import external JavaScript files through another JavaScript file, like @importin css.
On several sites, including StackOverflow itself, I noticed that adding a script tag to the DOM can solve this problem; however, this is done asynchronously, while the order of my files is important - the second file, for example, can rely on the first file in the list. When, say, jQuery first loads and then a dependency is loaded (plugin, etc.), the Dependency may finish loading earlier and will cause errors because jQuery does not exist yet.
Therefore, this does not seem like a choice. How can I synchronously load javascript files from another javascript file?
source
share