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)
scripttype. Specifies the type of the script. Some common values: A JavaScript MIME type like: application/javascript (default) or application/ecmascript.
The HTML <script> type Attribute is used to specify the MIME type of script and identify the content of the Tag. It has a Default value which is “text/javascript”. Syntax: <script type="media_type"> Attribute Values: It contains a single value i.e media_type which specifies the MIME type of script.
The <script> HTML element is used to embed executable code or data; this is typically used to embed or refer to JavaScript code. The <script> element can also be used with other languages, such as WebGL's GLSL shader programming language and JSON.
async: It is used to specify the script is executed asynchronously. charset: It is used to specify the character encoding used in an external script file. defer: It is used to specify that the script is executed when the page has finished parsing. src: It is used to specify the URL of an external script file.
Use <script type="text/javascript">
or simply <script>
(if omitted, the type
is the same). Do not use <script language="JavaScript">
; the language
attribute is deprecated.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With