There seems to be a new pattern appearing on the web — attaching window load listener through undeclared assignment: onload = function(){ /* ... */ }; I’d like to explain why it’s a good idea to avoid it. A conventional approach to perform this task is to explicitly assign to window.onload property. That is, not counting other means like DOM L2 methods — addEventListener (as well as proprietary attachEvent), or intrinsic event attributes — : window.onload = function(){ /* ... */ }; How does it work? A tempting “short” version takes advantage of Javascript loose nature with regards to variable declarations.
More
Support this project and others with 1-click micro-donations
