The code as written now assumes that either - window.onload is set explicitly, or - window.onload is undefined But if someone used jQuery to add a handler i.e. `jQuery( function( $ ) { $( window ).load( function () { ... } ); } );` or they used vanilla JS i.e. `window.addEventListener( 'load', function () { ... } );` then it's going to overwrite those handlers and they'll never run. For more info about how to attach event handlers/listeners, see https://stackoverflow.com/a/30915025/8524018