- 2

What is page load? What is the purpose of page load?

For page load, script must be inserted inside a body tag which is in html tag.

15th Apr 2020, 2:34 PM
Sandhya S
Sandhya S - avatar
1 Answer
+ 1
Sandhya S hello, If you do a web page with html,CSS and js, when the browser read the file it will read the html in the order it is constructed, if you put your external js file link within the <head> tags, it could results some errors as in your js file you could make use of elements of the html that haven't been read yet. To avoid that you can either add at the beginning of your js file that function (and wrap your code within it) : window.onload=()={ //Put your code here } This function ask the window to first load the html and then execute your script. Or, you can also put your <script> tag for the js file within the <body> tags at the very end, just before the closing </body> tag, this way it will be read last allowing elements of the html to be recognized by your script.
16th Apr 2020, 12:12 AM
EmmanueLZ.
EmmanueLZ. - avatar