document.addEventListener('DOMContentLoaded', function(){ // your code goes here }, false); code example
Example: listerner content loaded js
window.addEventListener('DOMContentLoaded', (event) => {
console.log('DOM fully loaded and parsed');
});