You should use event listeners if you want to be on the safe side window.onload can be overwritten and eventlistener adds an listener to the page and will not be overwritten
Good point. However for this demo I wanted to keep it simple. For those who are into JS and have more than one function set for onload, they should understand how it works. But eventlistener is a great alternative.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You should use event listeners if you want to be on the safe side
window.onload
can be overwritten andeventlistener
adds an listener to the page and will not be overwrittenGood point. However for this demo I wanted to keep it simple. For those who are into JS and have more than one function set for onload, they should understand how it works. But eventlistener is a great alternative.