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


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>


Updated on: 12-Sep-2019

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements