I'm loading a javascript file using jquery
with the usual:
// file application.js
$.getScript("module.js", function(data, textStatus, jqxhr) { ... });
So far so good. Except that module.js
uses a function declared in another module i.e., it contains the statement:
// file module.js
import { myFunction } from './library.js';
When the browser loads my application, it complains that:
Cannot use import statement outside a module
Is there a way to load the script module.js
as a module?
Thanks
Try loading the script in the html file as
<script type="module" src="module.js"></script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With