Svelte

svelte/kit-load-waterfall

A load function starts independent requests together and awaits parent() only after them, so data does not load in a chain.

moderatemanualfe-sveltekit

Why

await parent() waits for every layout above; a fetch written after it starts only then, and a second await fetch after the first waits again. Each step adds a full round trip, so the page renders after the sum of all requests instead of the slowest one.

Fix

Start requests that do not need parent data first (or together with Promise.all) and call await parent() after them. Move chains that depend on each other into a server load, close to the database. Return slow, non-essential data as an un-awaited promise and render it with {#await} so the page streams.

Examples

// bad: +page.js
export async function load({ fetch, parent }) {
  const { user } = await parent()
  const posts = await (await fetch('/api/posts')).json()
  return { user, posts }
}
// good
export async function load({ fetch, parent }) {
  const postsRes = fetch('/api/posts')
  const { user } = await parent()
  return { user, posts: await (await postsRes).json() }
}

Sources

Facts

Id
svelte/kit-load-waterfall
Severity
moderate
Check
manual a person reviews it; the report lists it as a checklist
Applies to
svelte
Only in projects with
sveltekit
Taught by the skill
fe-sveltekit SvelteKit apps
Since version
0.1.0

Rule file on GitHub

Read it in the terminal

npx github:dawidolko/frontend-skills explain svelte/kit-load-waterfall