These solutions will work:
As mentioned in comments use defer:
<script src="deferMe.js" defer></script>
document.onload = function ...
window.onload = function ...
Note that the last option is a better way to go since it is unobstrusive and is considered more standard.