Open
Description
Describe the problem
Consider the following code:
{#if iconData}
{#if iconData.paths}
{#each iconData.paths as path}
<path {...path} />
{/each}
{/if}
{/if}
It could be rewritten as:
{#each iconData?.paths || [] as path}
<path {...path} />
{/each}
This will save a larger amount of code than what is written in the source because the Svelte compiler must generate about ten lines for each if
statement. At the very least it shouldn't be too hard to combine consecutive if
statements into a single if
statement
This example is from a real project: RobBrazier/svelte-awesome#1058
Describe the proposed solution
Implement it as an optimization in the compiler
Alternatives considered
Document it (possibly at https://kit.svelte.dev/docs/performance) and make users handle it themselves
Importance
nice to have