On aminutewithbrendan, brendan eich makes an off hand comment implying that serving scripts as
<script type='text/javascript'></script>
is not correct because "text/javascript" is not a valid MIME type and he states "application/javascript" is a valid MIME type.
I only care about serving HTML5 as the doctype.
- Where are the MIME types for
<script>defined in the html5 W3C specification ? - What is browser support like for
"text/javascript"and"application/javascript"? - Which should be used ? Alternatively should we just not set
typeat all?
Literal Quote from brendan: (1:48)
… or script type equals application/javascript or application/ecmascript, those are the official MIME types or either one of those made-up ones from HTML4 like text/javascript …
Related:
The union of the related resources doesn’t really answer all three questions.
Nowhere, it has a list (which includes some experimental and deprecated ones) but states that you can use any MIME type you like. MIME types are defined by IANA and
text/javascriptis officially marked as obsolete in favour ofapplication/javascriptNot good enough. There are still plenty of browsers around that don’t recognise the latter. (This is, however, only a problem with the type attribute, you can set the HTTP Content-Type header correctly without worrying).
Since you only care about HTML 5, just omit the type attribute entirely. It is optional and the default language is JavaScript.