Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript ES6 Modules MIME Type [duplicate]

What is the right (or better) MIME Type for JavaScript ES6 modules (*.mjs): text/javascript, application/javascript or javascript/esm?

like image 506
Rosberg Linhares Avatar asked Jan 16 '20 16:01

Rosberg Linhares


1 Answers

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/

like image 160
Mathias Bynens Avatar answered Oct 16 '22 20:10

Mathias Bynens