脚本标记的type属性的javascript MIME类型是什么? [英] What is the javascript MIME type for the type attribute of a script tag?

查看:120
本文介绍了脚本标记的type属性的javascript MIME类型是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MIME 类型的javascript是什么?

What is the MIME type of javascript?

更具体地说,在脚本标记的type属性中放入什么是正确的? application / x-javascript text / javascript 似乎是主要的竞争者。

More specifically, what is the right thing to put in the "type" attribute of a script tag? application/x-javascript and text/javascript seem to be the main contenders.

推荐答案

这是一个常见的错误。 javascript的MIME类型多年未标准化。它现在正在正式 application / javascript

This is a common mistake. The MIME type for javascript wasn't standardized for years. It's now officially: "application/javascript".

这里真正的踢球者是大多数浏览器无论如何都不会使用该属性,至少在脚本标签的情况下不会。他们实际上偷看了数据包并确定了自己的类型。

The real kicker here is that most browsers won't use that attribute anyway, at least not in the case of the script tag. They actually peek inside the packet and determine the type for themselves.

所以底线是type =text / javascript没有做任何事情。 javascript是关注的,但它是 HTML 4 XHTML 1.0 的规范的一部分。

So the bottom line is that the type="text/javascript" doesn't do anything as far as the javascript is concerned, but it's part of the spec for both HTML 4 and XHTML 1.0.

这篇关于脚本标记的type属性的javascript MIME类型是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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