Best practice for using window.onload

Posted by Jennifer | Updated on

In this example, I have shared the best practice for using window.onload. I’d say the better/newer way of doing this would be to use a framework, or to just to use a simple implementation of the native addEventListener and attachEvent (for IE) methods, which allows you to remove the listeners for the events as well.

Here’s a cross-browser implementation:

If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@] Your question and answer will appear on and help other developers.

Related Questions & Answers