@exadel/esl
Version:
Exadel Smart Library (ESL) is the lightweight custom elements library that provide a set of super-flexible components
15 lines (14 loc) • 431 B
JavaScript
/**
* Execute callback in bounds of the next task with dom ready state precondition
*/
export function onDocumentReady(callback) {
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', function fn() {
document.removeEventListener('DOMContentLoaded', fn);
setTimeout(() => callback());
});
}
else {
setTimeout(() => callback());
}
}