Are there any important differences between declaring <script type="text/javascript"> </script> and <script language="javascript"> </script>?
(Note I'm not asking about these declarations vs. the blank "<script>" tag)
Are there any important differences between declaring <script type="text/javascript"> </script> and <script language="javascript"> </script>?
(Note I'm not asking about these declarations vs. the blank "<script>" tag)
The language attribute was used when <script> was introduced in HTML 3.2 and took a language name (such as JavaScript). The type attribute replaced it in HTML 4.0 (as everything describing non-HTML media started taking MIME types) and takes a MIME type (such as text/javascript). More recently it also supports the special value module for JavaScript modules (which support the import keyword).
Language is generally used to indicate the Javascript version that your script requires. Browsers that support the language attribute won't load or run the script if it doesn't support it. About the only use would be if you had critical Javascript functions where you needed workarounds for older browsers.