0

JavaScript in <head>

why is the js in the head? the website performance is not so good then... or i'm false?

22nd Nov 2016, 10:14 AM
Dominic Seela
Dominic Seela - avatar
2 Answers
+ 3
You are correct. Javascript is generally placed at the bottom of the <body> tag. This is becuase when loading a page, when JS is encountered the page loading is paused, while the script runs. Putitng it at the Bottom of the <body> means that the entire page can be fully loaded, before the browser encounters any scripts. It is mainly to prevent long, complex scripts from being run by the browser before the page is fully loaded. A complex script in the <head> tag could cause the page to stop loading for a few minutes while the script is executed.
22nd Nov 2016, 10:22 AM
Pink Lemonade
0
thanks :)
22nd Nov 2016, 10:56 AM
Dominic Seela
Dominic Seela - avatar