Syntax error Why prefer to put JavaScript in the footer of an HTML page?

Why prefer to put JavaScript in the footer of an HTML page?



With JavaScript, you can put JavaScript anywhere on the page, whether inside <head> or <body> tag. But, it is a good practice to add JavaScript in the footer i.e. just before closing the <body> tag. This is because −

  • It loads script faster.
  • It will not block any DOM content to load.
  • It loads the web page before loading JavaScript
  • Improves display speed
  • Page loads faster
Updated on: 2020-06-13T06:13:45+05:30

894 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements