Skip to content
Advertisement

When serving JavaScript files, is it better to use the application/javascript or application/x-javascript

The whole question fits in the title. And to add some context: I’m not asking what is the best according to what the specs are saying, but rather what works the best given the mix of browsers deployed nowadays.

Some data points:

  • Google uses text/javascript for the JS used on their home page.
  • Google uses text/javascript on Google Docs.
  • Google uses application/x-javascript to serve JavaScript files with their Ajax libraries service.
  • Yahoo uses application/x-javascript to serve their JS.
  • Yahoo uses application/x-javascript for the JavaScript served on their home page.

Advertisement

Answer

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

Therefore:

  • 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
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement