JavaScript/Other Script Types

The script element will work in most browsers, because JavaScript is currently the default scripting language of the world wide web. In HTML5, the current spec says that developers should omit the type attribute from script tags[1], although previously it was recommended to specify what type of script you are using in case the default scripting language changes.

<!-- Unnecessary, used to be recommended -->
<script type="text/javascript"></script>

<!-- New HTML5 code -->
<script></script>

Instead of specifying the scripting language individually in the script element itself, you may also use a meta tag in the head of the document to specify a default scripting language for the entire page.

<meta http-equiv="Content-Script-Type" content="text/javascript" />

While the text/javascript was formally obsoleted in April 2006 by RFC 4329 [2] in favour of application/javascript, it is still preferable to continue using text/javascript due to HTML validators' and Internet Explorer web browsers' inability to understand application/javascript [3]

References

edit
  1. https://html.spec.whatwg.org/dev/scripting.html#attr-script-type
  2. RFC 4329: Scripting Media Types
  3. "application/javascript" and "application/ecmasscript" media types not recognized.