Run your code at the right time by making sense of DOMContentLoaded, load, after typing in a URL and, if the stars are aligned properly, your page loads.
In pure JavaScript, the standard method to detect a fully-loaded page is using the load event indicates that all assets on the webpage have been loaded.
This method is a shortcut for.on('load', handler ). The load event is sent to an element when it and all sub-elements have been completely loaded. This event.