Possible Duplicate:
Javascript MIME Type
我注意到 MIME 类型 text/javascript
已被弃用,取而代之的是 application/javascript
。 Wikipedia seems to confirm this .然而,Javascript 以源代码形式分发,即文本。 application
一词对我来说听起来像是编译后的二进制文件。事实上,现代 Javascript 解释器确实对源文本执行 JIT 编译,从而生成一个应用程序,这意味着源文本本身并不是一个应用程序。那么为什么首选使用 application/javascript
MIME 类型呢?
根据 RFC 2045 :
In general, the top-level media type is used to declare the general type of data, while the subtype specifies a specific format for that type of data. Thus, a media type of "image/xyz" is enough to tell a user agent that the data is an image, even if the user agent has no knowledge of the specific image format "xyz". Such information can be used, for example, to decide whether or not to show a user the raw data from an unrecognized subtype -- such an action might be reasonable for unrecognized subtypes of text, but not for unrecognized subtypes of image or audio. For this reason, registered subtypes of text, image, audio, and video should not contain embedded information that is really of a different type. Such compound formats should be represented using the "multipart" or "application" types.
编辑
因此,虽然 JavaScript 确实是文本,但它也是“包含真正不同类型的嵌入信息的文本的注册子类型”,因此需要 application
定义的顶级媒体类型那个 RFC。
有许多 application/...
MIME 类型不是“应用程序”(可执行二进制文件或代码),例如:application/zip
(用于 Zip 存档) .因此,从这个意义上说,application
顶级媒体类型的命名颇具误导性。