It is not clear what you are trying to do, but in general you have several options.
Pre-load the script or install it through NPM . This is probably the preferred way to deal with external dependencies. Once it is local, you can easily import or require like any other module.
If it is absolutely necessary to load dynamically , you will need a third-party module, for example https://www.npmjs.com/package/scriptjs , which can easily load third-party modules at runtime and block the rest of the script from executing until it analyzed.
Use the <script> and include it on your page . This only works if it's a general dependency that can be loaded before everything else (maybe for a polyfill or a library that you depend on everywhere, like jquery.)
I hope this helps!
source share