What is the javascript MIME type for the type attribute of a script tag? [duplicate] What is the javascript MIME type for the type attribute of a script tag? [duplicate] javascript javascript

What is the javascript MIME type for the type attribute of a script tag? [duplicate]


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.

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.


Far out this is the first page I've found on the topic with any sense about it.

My collective research suggests:

  1. text/javascript as Keparo stated must be used in html4 and xhtml1 if you want it to validate. Though browsers ignore it.
  2. application/javascript is expected to be the new official MIME type if everyone agrees and when everything catches up.
  3. application/x-javascript (x meaning unofficial) is the current server side MIME reference for javascript.
  4. Everyone expects that as per usual, Microsoft will decide to do something completely different to further confuse and stuff up the matter.

Summary: For now, if you want your html/xhtml to work in MSIE and validate with W3C then declare type="text/javascript". If you want your web server to know that you mean javascript then use application/x-javascript.


text/javascript

I believe IE doesn't accept application/x-javascript

Specifying the scripting language