Use DOMContentLoaded to make sure the DOM is ready and loaded
- The `DOMContentLoaded` event can be used to make sure the DOM is loaded. - Note that external resources like images may not be loaded at that point. - via: https://javascript.info/onload-ondomcontentloaded
Example:
Code
}
document.;
You can also do it with an anonymous funciton:
Code
document.;