Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is the new standard `application/javascript` as opposed to `text/javascript`? [duplicate]

Possible Duplicate:
Javascript MIME Type

It has been brought to my attention that the MIME type text/javascript is deprecated in favour of application/javascript. Wikipedia seems to confirm this. However, Javascript is distributed in source form, i.e. text. The term application sounds to me like a compiled binary. In fact, modern Javascript interpreters do in fact perform JIT compilation on the source text, thus producing an application, thus implying that the source text itself was not an application. So why is it preferred to use the application/javascript MIME type?

like image 981
dotancohen Avatar asked Nov 27 '12 18:11

dotancohen


1 Answers

According to 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.

Edit

So although JavaScript is indeed text, it's also a "registered subtype of text containing embedded information that is really of a different type", and therefore requires the application top-level media type as defined by that RFC.

There are many application/... MIME types which are not "applications" (executable binaries or code), eg: application/zip (for Zip archives). So in this sense, the application top-level media type is rather misleadingly named.

like image 86
TachyonVortex Avatar answered Sep 21 '22 22:09

TachyonVortex