Depending on the complexity or nature of your JavaScript,
sometimes it is necessary to wait until the entire page has loaded before
that script is run to prevent any potential problems or make sure the aspect
of the page you're manipulating has been downloaded. This is where the
onload event handler comes in handy.

Executing a JavaScript function after the page has loaded is
necessary sometimes