А, не, нашел...
function main()
{
alert('main')
}
function listener()
{
alert('listener')
if(document.readyState === "loading") document.addEventListener('DOMContentLoaded', main)
else main()
}
function init()
{
alert('init')
setTimeout(listener, 3000)
}
init()