diff --git a/src/js/domready.js b/src/js/domready.js index 82a1f3e335..9d964fbd35 100644 --- a/src/js/domready.js +++ b/src/js/domready.js @@ -9,6 +9,11 @@ const onReady = () => { isReady = true; callbacks.forEach(fn => fn.call()); document.removeEventListener(eventReady, onReady); + + const event = new CustomEvent('onsDOMReady'); + + document.dispatchEvent(event); + window.onsDOMReady = true; }; export default function ready(fn, ready = isReady) { diff --git a/src/js/polyfills/await-polyfills.js b/src/js/polyfills/await-polyfills.js index ab01ffac2a..98177ff3b9 100644 --- a/src/js/polyfills/await-polyfills.js +++ b/src/js/polyfills/await-polyfills.js @@ -4,8 +4,6 @@ export const awaitPolyfills = new Promise(resolve => { if (window.polyfillsLoaded) { resolve(); } else { - document.addEventListener(polyfillsReadyEvent, () => { - resolve(); - }); + document.addEventListener(polyfillsReadyEvent, resolve); } });