1. Place the script below the DOM object (HTML element) it uses or references.
ie. The script block must be included at any point after the HTML element tag in the source code of the page.
2. Use window.onload function:
<head> section, but in this case you will need to listen for the
window.onload event as follows: