Skip to content

Commit

Permalink
await
Browse files Browse the repository at this point in the history
  • Loading branch information
FelipeSimoes committed Jan 9, 2024
1 parent 404d314 commit 84ae111
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions scripts/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,14 @@ export async function init(node = document) {

const data = retriveDataFrom(blocks);
const lcp = window.raqnLCP;
const prio = data.slice(0, 2);
const rest = data.slice(2);
const start = ({ name, el }) => {
const loader = new ComponentLoader(name, el);
return loader.decorate();
};
await Promise.all([
...lcp.map(({ name, el }) => start({ name, el })),
...prio.map(({ name, el }) => start({ name, el })),
]);
await Promise.all([...lcp.map(({ name, el }) => start({ name, el }))]);

await Promise.all(
rest.map(({ name, el }) => setTimeout(() => start({ name, el }))),
data.map(({ name, el }) => setTimeout(() => start({ name, el }))),
);

// reload on breakpoint change
Expand Down

0 comments on commit 84ae111

Please sign in to comment.