Svelte · Senior · Question 51 of 75

How can you make a code-heavy component load only when needed?

{#await import("./Chart.svelte") then { default: Chart }}
  <Chart data={stats} />
{/await}

Explanation

SvelteKit already splits code per route; dynamic imports help with heavy widgets inside a page.

Further reading

Problem with a question

Svelte · Senior · question 51

Test yourself

Take the Svelte · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz