I have a question concerning the difference between:
1. <body onload="myFunction()">
2. window.onload = myFunction;
3. window.addEventListner("load", myFunction)
4. window.onload = myFunction();
So are they all equivalent? and which one is the best practice to use?
](https://stackoverflow.com/questions/191157/window-onload-vs-body-onload) and [attachEvent / addEventListener to Window onload / load - preferred way](https://stackoverflow.com/questions/5436521/attachevent-addeventlistener-to-window-onload-load-preferred-way). See also [How to make JavaScript execute after page load?](https://stackoverflow.com/questions/807878/how-to-make-javascript-execute-after-page-load)
– Inigo Dec 07 '21 at 23:24