Performance: Text interpolation with {}
LOW IMPACT
Text interpolation affects how quickly dynamic text content appears on the page and how often the DOM updates when data changes.
<script> let name = 'Alice'; $: message = `${name} is logged in`; </script> <p>{message}</p>
<script> let name = 'Alice'; </script> <p>{name + ' is logged in'}</p>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Direct string concatenation in interpolation | Updates text node on each change | 1 reflow per update | 1 paint per update | [X] Bad |
| Precomputed string variable interpolation | Updates text node only when variable changes | 1 reflow per update | 1 paint per update | [OK] Good |