提供 JavaScript 文件时,使用 application/javascript 还是 application/x-javascript 更好 [英] When serving JavaScript files, is it better to use the application/javascript or application/x-javascript
本文介绍了提供 JavaScript 文件时,使用 application/javascript 还是 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.
一些数据点:
- Google 对其主页上使用的 JS 使用
text/javascript
. - Google 在 Google 文档中使用
text/javascript
. - Google 使用
application/x-javascript
来提供带有 Ajax 的 JavaScript 文件图书馆服务. - 雅虎使用
application/x-javascript
来为他们的 JS 提供服务. - 雅虎将
application/x-javascript
用于其主页上提供的 JavaScript.
- 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.
推荐答案
根据 IETF 的 ECMAScript 媒体类型更新截至 2021 年 2 月 22 日,RFC-4329 已过时.
According to the IETF's ECMAScript Media Types Updates as of 22 February 2021, the RFC-4329 is obsolete.
因此:
text/javascript
是推荐的标准(IETF 和 MDN)application/x-javascript
在决定迁移到......时处于实验阶段application/javascript
已过时
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
这篇关于提供 JavaScript 文件时,使用 application/javascript 还是 application/x-javascript 更好的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文