I execute this code in the head of the document:
console.log('DOMContentLoaded event');
document.addEventListener( "DOMContentLoaded", ready, false );
However, the function doesnt get called, even after the page is ready? What is inside the console log does get printed
Notice that i add a javascript file dynamically (it is not hardcoded), and i think it is quite late in the script.. it is after the window.onload event? may it be the reason? any way I can trigger the event?