What is the right (or better) MIME Type for JavaScript ES6 modules (*.mjs): text/javascript, application/javascript or javascript/esm?
text/javascript
is the correct JavaScript MIME type per the HTML Standard, which states:
Servers should use
text/javascript
for JavaScript resources. Servers should not use other JavaScript MIME types for JavaScript resources, and must not use non-JavaScript MIME types.
And also:
[…] the MIME type used to refer to JavaScript in this specification is
text/javascript
, since that is the most commonly used type, despite it being an officially obsoleted type according to RFC 4329.
Work is underway to reflect this reality in an RFC at the IETF level: https://datatracker.ietf.org/doc/draft-ietf-dispatch-javascript-mjs/
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