window.updateLoop = []; (() => { let updLoop = setInterval(() => { updateLoop.forEach(f => f()); }, 30000); let everythingLoaded = setInterval(function() { if (/loaded|complete/.test(document.readyState)) { clearInterval(everythingLoaded); updateLoop.forEach(f => f()); } }, 10); })();