Difference between application/x-javascript and text/javascript content types(application/x-javascript 和 text/javascript 内容类型之间的区别)
问题描述
这些标头有什么区别?
Content-Type: application/javascript
Content-Type: application/x-javascript
Content-Type: text/javascript
哪个最好,为什么?
请不要说它们是相同的 - 如果它们相同,就不会有三个.我知道两者都有效 - 但我想知道它们的区别.
Please do not say they are identical - if they were identical there would not have been three of them. I know both work - but I would like to know the difference.
推荐答案
text/javascript
已过时,application/x-javascript
是实验性的(因此 >x-
前缀)在 application/javascript
可以标准化之前的过渡期.
text/javascript
is obsolete, and application/x-javascript
was experimental (hence the x-
prefix) for a transitional period until application/javascript
could be standardised.
您应该使用 application/javascript
.这在 RFC.
就浏览器而言,没有区别(至少在 HTTP 标头中).这只是一个更改,以便 text/*
和 application/*
MIME 类型组在可能的情况下具有一致的含义.(text/*
MIME 类型旨在用于人类可读的内容,JavaScript 并非旨在直接向人类传达意义).
As far a browsers are concerned, there is no difference (at least in HTTP headers). This was just a change so that the text/*
and application/*
MIME type groups had a consistent meaning where possible. (text/*
MIME types are intended for human readable content, JavaScript is not designed to directly convey meaning to humans).
请注意,在脚本元素的 type
属性中使用 application/javascript
会导致脚本在某些较旧的浏览器中被忽略(因为是未知语言).要么继续使用 text/javascript
,要么完全省略该属性(这在 HTML 5 中是允许的).
Note that using application/javascript
in the type
attribute of a script element will cause the script to be ignored (as being in an unknown language) in some older browsers. Either continue to use text/javascript
there or omit the attribute entirely (which is permitted in HTML 5).
这在 HTTP 标头中不是问题,因为浏览器普遍(据我所知)要么完全忽略脚本的 HTTP 内容类型,要么足够现代以识别 application/javascript
.
This isn't a problem in HTTP headers as browsers universally (as far as I'm aware) either ignore the HTTP content-type of scripts entirely, or are modern enough to recognise application/javascript
.
这篇关于application/x-javascript 和 text/javascript 内容类型之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:application/x-javascript 和 text/javascript 内容类型之间的区别
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- addEventListener 在 IE 11 中不起作用 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- Flexslider 箭头未正确显示 2022-01-01
- 失败的 Canvas 360 jquery 插件 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- Fetch API 如何获取响应体? 2022-01-01
- 400或500级别的HTTP响应 2022-01-01