on dom ready javascript code example
Example 1: dom ready js
document.addEventListener("DOMContentLoaded", function() {
// code
});
Example 2: wait for the dom to load javascript
document.addEventListener('DOMContentLoaded', (event) => {
//the event occurred
})