Answer the question
In order to leave comments, you need to log in
Is it possible to somehow load modules by url?
I would like to have such a construction
import(' https://site.com/module.js ').then(function(module) {
// ...
})
Answer the question
In order to leave comments, you need to log in
the solution was to use https://www.npmjs.com/package/little-loader
Read the article about document.createElement(tag)
Create a tag <script>
, the browser loads the script itself, register a variable at the end of the body of the loaded script, and on the page itself, where you load it, periodically ask for the presence of this variable, if it is registered - it means the script has loaded and then do the following what you wanted.
What exactly is the problem? Webpack has import/export, and it also has require.
The syntax is perhaps different, something like (better check in the documentation):
https://site.com/module.js: export function module module() { ... }
And loading:
import {module} from " https: //site.com/module.js "
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question