Performance: Declaring props with export let
MEDIUM IMPACT
This affects the initial rendering speed and update responsiveness of Svelte components by controlling how data is passed and tracked.
<script> export let data; </script> <!-- Parent passes data directly as prop --> <Child {data} />
<script> let data; let childRef; </script> <!-- Parent manually updates child via DOM or events --> <Child bind:this={childRef} /> <!-- Parent updates child by calling methods or manipulating DOM directly -->
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Manual DOM updates or event calls for passing data | High - multiple direct DOM manipulations | Multiple reflows per update | High paint cost due to many changes | [X] Bad |
| Using export let props for data passing | Low - reactive updates only | Single reflow per update | Low paint cost with minimal changes | [OK] Good |