mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[ADD] utils: add whenReady function
This commit is contained in:
@@ -188,3 +188,11 @@ export function loadJS(url: string): Promise<void> {
|
|||||||
loadedScripts[url] = promise;
|
loadedScripts[url] = promise;
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function whenReady(fn) {
|
||||||
|
if (document.readyState === "complete") {
|
||||||
|
fn();
|
||||||
|
} else {
|
||||||
|
document.addEventListener("DOMContentLoaded", fn, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user