Should I write my script in the body or the head of the HTML?

JavascriptWeb DevelopmentFront End Technology

It is suggested that you should place the script within the <head> tag or <body> tag. It is good for performance to add JavaScript in <body> element.

Example

Here is an example to add <script> under <body>…</body> −

<html>
   <body>
      <script>
         <!--
            document.write("Hello World!")
         //-->
      </script>
   </body>
</html>
raja
Published on 10-Jan-2018 10:35:10
Advertisements