Where the Script is Located on a page?

The script in a page will be executed immediately while the page loads into the browser.

Script in the HEAD section:

When we want a Script executed when the script is called, or when an event is triggered again, we placed the Script in the HEAD section of the HTML document.

Script in the BODY section:

Script to be executed when the page loads go in the BODY section of the HTML document.

When the Script is placed in the BODY section of the HTML document, it generates the content of the page.