javascript when dom loaded code example
Example 1: javascript wait for document load
document.addEventListener("DOMContentLoaded", function(event) {
//do work
});
Example 2: dom is loaded
document.addEventListener('DOMContentLoaded', (event) => {
console.log('DOM fully loaded and parsed');
});