You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 10, 2022. It is now read-only.
I was told that text/javascript is obsolete and it should be application/javascript
I am a web technology newbie.
So what is the preferred MIME type and file extension for JavaScript modules?
Is it text/javascript or application/javascript with .mjs or not?
FWIW, both recent Chrome 74.0.3729 and recent Firefox 60.6 are accepting text/javascript for .mjs JavaScript modules. But I don't know if it is a bug or a feature.
And yes, it is obsolete, or at least it used to be. It’s a head-scratcher why the spec writers chose that MIME type rather than what was the non-deprecated MIME type at the time, application/javascript. So basically both sides are right: you should be using text/javascript, even though it’s obsolete.
The spec, and browsers, don’t care at all about file extensions. You could end your filename with .mjs, with .js, with .foo, or with whatever you want. The file extension is only relevant in that it’s probably what your web server uses to choose what MIME type to serve the file as. As long as it chooses text/javascript, you’re fully compliant.
https://developers.google.com/web/fundamentals/primers/modules is mentioning the
.mjs
extension for JavaScript modules associated totext/javascript
MIME type.On Debian, I submitted the Debian bug#927300 related to that.
I was told that
text/javascript
is obsolete and it should beapplication/javascript
I am a web technology newbie.
So what is the preferred MIME type and file extension for JavaScript modules?
Is it
text/javascript
orapplication/javascript
with.mjs
or not?FWIW, both recent Chrome 74.0.3729 and recent Firefox 60.6 are accepting
text/javascript
for.mjs
JavaScript modules. But I don't know if it is a bug or a feature.Respectful regards.
Basile Starynkevitch
<[email protected]>
http://starynkevitch.net/Basile - Bourg La Reine, France
The text was updated successfully, but these errors were encountered: