Should I include type=“text/javascript” in my SCRIPT tags?

JavascriptWeb DevelopmentFront End Technology

The type attribute in JavaScript is optional since the introduction of HTML5 brought some new improvements. JavaScript became the default language for HTML5 and modern browsers. So, now adding text/javascript isn’t required in <script> tag.

This attribute is what is now recommended to indicate the scripting language in use and its value should be set to "text/javascript".

Here you can see how it is used:

<html>
   <body>
      <script language="javascript" type="text/javascript">
         <!--
            document.write("Hello World!")
         //-->
      </script>
   </body>
</html>


raja
Published on 09-Jan-2018 10:23:34
Advertisements