WAIT! for DOM to be loaded
document.addEventListener("DOMContentLoaded", function(){
console.log("DOM has been loaded!");
});
Some examples will show putting the script
before the body end tag </body>
instead of setting a DOMContentLoaded
event listener on the document