diff --git a/scripts/init.js b/scripts/init.js index 7ba05fed..e7c1a617 100644 --- a/scripts/init.js +++ b/scripts/init.js @@ -71,19 +71,19 @@ export async function init(node = document) { return loader.decorate(); }; - Promise.all([ + await Promise.all([ ...lcp.map(({ name, el }) => start({ name, el })), ...priority.map(({ name, el }) => start({ name, el })), ]); - // if (!loaded) { - // window.addEventListener('load', () => { - // loaded = true; - // return rest.map(({ name, el }) => setTimeout(() => start({ name, el }))); - // }); - // } else { - rest.map(({ name, el }) => setTimeout(() => start({ name, el }))); - // } + if (!loaded) { + window.addEventListener('load', () => { + loaded = true; + return rest.map(({ name, el }) => setTimeout(() => start({ name, el }))); + }); + } else { + rest.map(({ name, el }) => setTimeout(() => start({ name, el }))); + } // reload on breakpoint change window.raqnBreakpoint = getBreakPoint();