RFC4329 and IANA says it's application/javascript
, and text/javascript
is obsolete. However, HTML standard (by WHATWG) says servers should use text/javascript
rather than other obsolete types.
Why is there such a difference? What is the correct MIME type we should use for javascripts? Does it mean that web servers should use text/javascript
for scripts meant to be run by the browsers and use application/javascript
in other cases (e.g. for a js file to be downloaded)?
Not totally sure what was the historical reason when such decision has been made. Anyway, the latest RFC 9239 and IANA both suggest that text/javascript
be the canonical MIME type for .js
files.