ondomcontentloaded javascript
window.addEventListener('DOMContentLoaded', (event) => { console.log('DOM fully loaded and parsed'); });
Source: developer.mozilla.org
run function once domcontentloaded javascript
window.addEventListener('DOMContentLoaded', (event) => { myFunction(); }); // Once the DOM has been loaded, the function will run
javascript domcontentloaded
// initialize the function "init" when the page completely loads document.addEventListener('DOMContentLoaded', init); function init() { console.log('The page successfully loaded!'); }