Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

ES6 local (file://) javascript modules and scripts behave inconsistently

  • No replies
  • 1 has this problem
  • 4 views
more options

I have been developing a relatively simple utility in html and javascript that I am simply running locally. The primary reason for running it in a browser at all is that I can design an interface fairly quickly in html and css. I don't intend to run this on a webserver (though it would of course be possible to do so). Now initially everything would simply fit in the html, but later I moved the javascript portion into separate files. This all worked well, until I wanted to switch to using ecmascript 6 modules. Simply adding the type="module" attribute breaks everything since my sourced script tags trigger the error described in https://developer.mozilla.org/nl/docs/Web/HTTP/CORS/Errors/CORSRequestNotHttp.

Now I understand the reasoning behind that change, but I do believe the behaviour in this context is very strange and definitely inconsistent. I believe the underlying cause may be related to the fact that javascript modules are loaded asynchronously while scripts are loaded synchronously.

I could (and probably will) change my configuration to allow the loading of resources from the same directory again (I am aware of the risks), but how is loading a static resource asynchronously any more dangerous than loading said static resource synchronously?

I have been developing a relatively simple utility in html and javascript that I am simply running locally. The primary reason for running it in a browser at all is that I can design an interface fairly quickly in html and css. I don't intend to run this on a webserver (though it would of course be possible to do so). Now initially everything would simply fit in the html, but later I moved the javascript portion into separate files. This all worked well, until I wanted to switch to using ecmascript 6 modules. Simply adding the type="module" attribute breaks everything since my sourced script tags trigger the error described in [http://example.com https://developer.mozilla.org/nl/docs/Web/HTTP/CORS/Errors/CORSRequestNotHttp]. Now I understand the reasoning behind that change, but I do believe the behaviour in this context is very strange and definitely inconsistent. I believe the underlying cause may be related to the fact that javascript modules are loaded asynchronously while scripts are loaded synchronously. I could (and probably will) change my configuration to allow the loading of resources from the same directory again (I am aware of the risks), but how is loading a '''static''' resource asynchronously any more dangerous than loading said static resource synchronously?