0

Can't understand it???Anyone help.

It's a good idea to place scripts at the bottom of the <body> element. This can improve page load, because HTML display is not blocked by scripts loading.

27th Sep 2019, 8:47 AM
Nafiyeen Hossain
2 odpowiedzi
+ 2
when classic HTML page is downloaded, starts parssing html and displaying it's elements. If during this process found part for JS in html code, process is stopped and start process to download and executing JS code parts. After end of js processing, continues to HTML processing. So user notice gap in displaying web page for seconds, and there is nothing interesting for him on screen in this time. but this problem can be solved modern way: "The current state-of-the-art is to put scripts in the <head> tag and use the async or defer attributes."
27th Sep 2019, 10:13 AM
zemiak
+ 1
In local projects or in small applications we cannot notice that difference of loading the page.Whenever you write script before <body> or in <head> it loads all scripts at once.It may happen that some code may manipulate DOM but as <body> is not executed is may throws an error. So, if you place scripts at the bottom of the <body> element then it also improves the display speed, because interpretation of scripts slow down the display.
28th Sep 2019, 4:27 AM
Shaili Shah
Shaili Shah - avatar