I ran into an issue today where my script with type="module" is executed before my main.js script which holds some important functions. Or it has not yet finished loading the first script before it loads the second.
Then my module is complaining that a function is not defined which was defined in my main.js. This doesn't happen every time though. Other times my main.js gets loaded first and everything works the way it should.
<script src="http://localhost/newblog/js/main.js"></script>
<script type="module" src="http://localhost/newblog/js/blog.js"></script>
Is there a way to make the second script wait until my first script has finished loading and only then load the second script?