Text / javascript vs application / javascript

I'm interested in the semantics of application/javascript MIME types compared to text/javascript .

Obviously, one should be executed, and the other should be just text.

I see application/javascript when viewing the headers of an external .js load.

 HTTP/1.1 200 OK Date: Mon, 13 Jan 2014 18:32:58 GMT Server: Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/0.9.8e-fips-rhel5 Content-Type: application/javascript Content-Length: 856 keep-alive: timeout=5, max=59 Via: 1.1 (jetty) Accept-Ranges: bytes 

If this application/javascript will execute javascript, why don't we use

 <script type="application/javascript"> // some js code. </script> 

And vice versa, why is the external js load not text/javascript ?

+24
javascript mime-types
Jan 13 '14 at 18:41
source share
1 answer

In this text/javascript deprecated . Use application/javascript instead.

text / javascript (Deprecated): JavaScript; Defined and deprecated in RFC 4329 to discourage its use in favor of application / JavaScript. However, / javascript text is allowed in HTML 4 and 5 and, unlike the / javascript application, has cross-browser support. The "type" attribute of a tag in HTML5 is optional and there is no need to use it at all, since all browsers always assumed the correct one by default (even in HTML 4, where the specification was required).

This standard is incompatible with IE <= 8.

+33
Jan 13 '14 at 18:46
source share
— -



All Articles