I have a JavaScript file I've linked to an html file. The file links fine whenever I don't have anything imported into it, but whenever I import another file into it, it isn't even loaded.
What the JavaScript file looks like when it loads in.
//import './the_story/project.js';
function savE(){
alert("Saved!");
}
function loaD(){
alert("Loaded!")
}
What the JavaScript file looks like when it doesn't load in.
import './the_story/project.js';
function savE(){
alert("Saved!");
}
function loaD(){
alert("Loaded!")
}
I'm honestly pretty stumped on this. I've tried having the script inside the html file itself and it still didn't work. It claimed my functions were undefined.
CodePudding user response:
In your html import your javascript file as module
like so
<script type="module" src="main.js"></script>
for futher reading about normal script file and module please read official docs
CodePudding user response:
Did your script tag have type="module"?