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/javascriptfor the JS used on their home page. - Google uses
text/javascripton Google Docs. - Google uses
application/x-javascriptto serve JavaScript files with their Ajax libraries service. - Yahoo uses
application/x-javascriptto serve their JS. - Yahoo uses
application/x-javascriptfor 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/javascriptis a recommended standard (both by IETF and by MDN)application/x-javascriptwas experimental while deciding to move to…application/javascriptis obsolete