Performance: Use directive syntax
MEDIUM IMPACT
This affects how efficiently Svelte updates the DOM and handles reactive behavior during user interactions.
<input bind:value={name} /><input value={name} on:input={(e) => name = e.target.value} />| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Manual event handling for input | Multiple event listeners | Multiple reflows per keystroke | High paint cost due to frequent updates | [X] Bad |
| Svelte bind directive for input | Minimal DOM updates | Single reflow per change | Low paint cost | [OK] Good |
| CSS visibility toggle for conditional content | DOM nodes remain | Reflows on layout changes | Higher paint cost | [X] Bad |
| Svelte if directive for conditional content | DOM nodes added/removed | Reflows only when toggled | Lower paint cost | [OK] Good |