[ACCEPTED]-When serving JavaScript files, is it better to use the application/javascript or application/x-javascript-content-type

Accepted answer
Score: 129

According to the IETF's ECMAScript Media Types Updates as of 22 February 1 2021, the RFC-4329 is obsolete.


  • text/javascript is a recommended standard (both by IETF and by MDN)
  • application/x-javascript was experimental while deciding to move to…
  • application/javascript is obsolete
Score: 12

In most situations, the mime type the server 3 sends makes no practical difference. I 2 would go with application/javascript, which is also recommended 1 by an RFC.

Score: 12

Here's the 2020 answer to this question.

text/javascript is 16 the correct JavaScript MIME type per the HTML Standard, which 15 states:

Servers should use text/javascript for JavaScript 14 resources. Servers should not use other 13 JavaScript MIME types for JavaScript resources, and 12 must not use non-JavaScript MIME types.

And 11 also:

[…] the MIME type used to refer to JavaScript 10 in this specification is text/javascript, since that is 9 the most commonly used type, despite it 8 being an officially obsoleted type according 7 to RFC 4329.

Work is underway to reflect 6 this reality in an RFC at the IETF level: https://datatracker.ietf.org/doc/draft-ietf-dispatch-javascript-mjs/

Any 5 claim that "text/javascript is the obsolete one" is 4 saying so based on RFC 4329, which both 3 the HTML Standard and the abovementioned 2 IETF draft (i.e. an upcoming RFC) are explicitly 1 correcting.

Score: 7

If you choose to use application/javascript 4 for js in your pages, IE7 and IE8 will not 3 run your script! Blame Microsoft all you 2 want, but if you want most people to run 1 your pages use text/javascript.

Score: 7

It used to be language="javacript". Then it changed to type="text/javascript". Now 13 it is type="application/javacript". Ok this is getting dumb. Some of 12 the older browsers don't recognize the new 11 application/javascript, but still recognize the older text/javascript. I plan 10 to continue using this, or else I'll waste 9 hours of my time trying to change EVERY 8 instance of text/javascript into application/javascript.
Now some day the opposite 7 might be true. Some day the newest browsers 6 might reject the old technique in order 5 to be strictly standard's compliant.
But 4 until people viewing my website start complaining 3 that "ever since upgrading my browser, about 2 50% of your website disappeared", I have 1 no motive to change the code in my website.

Score: 4

It has been "text/javascript" but 3 this is obsolete (see the IANA List) and now it should 2 be "application/javascript" (see 1 another IANA List).

More Related questions