Javascript MIME [英] Javascript MIME

查看:79
本文介绍了Javascript MIME的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否最好使用application/javascript或application/ecmascript,以及是否应该使用application/languagename而不是其他语言的text/languagename.

I would like to know if is better to use application/javascript or application/ecmascript and if i should use application/languagename instead of text/languagename with other languages.

推荐答案

IANA(官方MIME类型注册表)列出了text/javascripttext/ecmascript已过时(通过 RFC 4329 ).

Officially, IANA (keepers of the official MIME type registry) lists text/javascript and text/ecmascript as obsolete (via RFC 4329).

在这两个中,最容易使用application/javascript. application/ecmascript的使用带来了更严格的字符编码要求,并减少了4329中指定的错误处理.

Of those two, it easiest to use application/javascript. The use of application/ecmascript brings with it stricter character encoding requirements and less forgiving error handling as specified in 4329.

实际上,如果您想在IE中工作,您必须使用text/javascript >.

Practically, you have to use text/javascript if you want it to work in IE.

此外,我的建议是完全跳过<script>标签的type属性.没有浏览器,每个浏览器都可以运行您的JS. (不过,您仍然需要提供HTTP text/javascripttext/javascript的.js文件.)

Also, my recommendation is to skip the type attribute of <script> tags entirely. Every browser will run your JS just fine without. (You still need to serve .js files with a HTTP Content-Type of text/javascript, though.)

这篇关于Javascript MIME的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆