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?
Yes, they are all equivalent. It is the same "load" event. I prefer to use DOMContentLoaded. That's what I check for before manipulating the DOM.
https://developer.mozilla.org/en-US/docs/Web/API/Window/DOMContentLoaded_event