Skip to main content
deleted 6 characters in body
Source Link
ddavison
  • 28.9k
  • 17
  • 88
  • 113

I am curious about the semantics of the MIME types application/javascript versus text/javascript.

Obviously,Apart from the obvious - one is supposedintended to be executed, and the other is supposed to be just text.

I see application/javascript when looking at 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 the javascript, why don't we use

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

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

I am curious about the semantics of the MIME types application/javascript versus text/javascript.

Obviously, one is supposed to be executed, and the other is supposed to be just text.

I see application/javascript when looking at 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 the javascript, why don't we use

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

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

I am curious about the semantics of the MIME types application/javascript versus text/javascript.

Apart from the obvious - one is intended to be executed, and the other is text.

I see application/javascript when looking at 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 the javascript, why don't we use

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

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

Source Link
ddavison
  • 28.9k
  • 17
  • 88
  • 113

text/javascript vs application/javascript

I am curious about the semantics of the MIME types application/javascript versus text/javascript.

Obviously, one is supposed to be executed, and the other is supposed to be just text.

I see application/javascript when looking at 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 the javascript, why don't we use

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

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