From cc8093f5ef2ac77e532bae933ce82fd8689f06ca Mon Sep 17 00:00:00 2001 From: paoloricciuti Date: Tue, 19 Nov 2024 17:53:39 +0100 Subject: [PATCH] chore: parallelize --- packages/svelte/src/internal/server/index.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/svelte/src/internal/server/index.js b/packages/svelte/src/internal/server/index.js index 9d205f1526..472569c4bd 100644 --- a/packages/svelte/src/internal/server/index.js +++ b/packages/svelte/src/internal/server/index.js @@ -177,9 +177,7 @@ export async function renderStaticHTML(component, options) { try { payload = render_payload(component, options); if (payload.async) { - for (let async_fn of payload.async) { - await async_fn(); - } + await Promise.all(payload.async.map((fn) => fn())); } let head = payload.head.out + payload.head.title; @@ -565,9 +563,7 @@ function await_block($$payload, promise, pending_fn, then_fn, catch_fn) { } } if ($$payload.async && new_payload.async) { - for (let async_replace of new_payload.async) { - await async_replace(); - } + await Promise.all(new_payload.async.map((fn) => fn())); } $$payload.out = $$payload.out.replace(replace_marker, new_payload.out); $$payload.head.out = $$payload.head.out.replace(replace_marker, new_payload.head.out);