diff --git a/src/utils.ts b/src/utils.ts index 7e23050f..0c0e2f11 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -188,3 +188,11 @@ export function loadJS(url: string): Promise { loadedScripts[url] = promise; return promise; } + +export function whenReady(fn) { + if (document.readyState === "complete") { + fn(); + } else { + document.addEventListener("DOMContentLoaded", fn, false); + } +}