Traditionally, to call a JavaScript function once the page has loaded, you\'d add an onload attribute to the body containing a bit of JavaScript (usually only c
For detect loaded html (from server) inserted into DOM use MutationObserver or detect moment in your loadContent function when data are ready to use
let ignoreFirstChange = 0;
let observer = (new MutationObserver((m, ob)=>
{
if(ignoreFirstChange++ > 0) console.log('Element added on', new Date());
}
)).observe(content, {childList: true, subtree:true });
// TEST: simulate element loading
let tmp=1;
function loadContent(name) {
setTimeout(()=>{
console.log(`Element ${name} loaded`)
content.innerHTML += `My name is ${name}`;
},1500*tmp++)
};
loadContent('Senna');
loadContent('Anna');
loadContent('John');