A slightly better approach than <body onload="…">

A tiny little quick tip for javascript beginners.

While you still can execute javascript code upon page loading completion with:

<body onload="jsFunc();">

You can just attach or define an onload event to body in the normal code flow:

window.onload = function() {
	jsFunc();
}
Scroll to Top