When I try to import a JS module dynamically using the code below, I get "Uncaught SyntaxError: unexpected reserved word"
in both, Firefox and Chrome but According to MDN it should work.
let module = await import('/modules/my-module.js');
When I use .then()
instead of await
, everything works just fine. Is MDN wrong?
You should write "async" in this function declaration
const my_func = async (arg1,arg2) => {
let module = await import('/modules/my-module.js');
}
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function