Performance: Slot fallback content
MEDIUM IMPACT
This affects initial rendering speed and visual stability by controlling whether default content is rendered when no slot content is provided.
<MyComponent> <!-- no slot content provided --> </MyComponent> <!-- Inside MyComponent.svelte --> <slot> <p>Default fallback content</p> </slot>
<MyComponent> <!-- no slot content provided --> </MyComponent> <!-- Inside MyComponent.svelte --> <slot></slot>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| No slot fallback content | Minimal initially, but increases when slot content is added dynamically | Multiple reflows if slot content changes after initial render | Higher paint cost due to layout shifts | [X] Bad |
| With slot fallback content | Stable DOM nodes from start | Single layout pass on initial render | Lower paint cost with stable layout | [OK] Good |