Performance: First Svelte component
This affects the initial page load speed and time to interactive by controlling how much JavaScript and DOM nodes are created.
<script> let count = 0; </script> <button on:click={() => count++}> Clicked {count} times </button>
<script> let count = 0; // Unused heavy library import import _ from 'lodash'; </script> <button on:click={() => count++}> Clicked {count} times </button>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Simple component without heavy imports | Minimal DOM nodes | 1 reflow on initial render | Low paint cost | [OK] Good |
| Component with large unused library import | Same DOM nodes | 1 reflow on initial render | Low paint cost | [X] Bad |
<script>
let count = 0;
</script>
<button on:click={() => count++}>Clicked {count} times</button><script>
let message = 'Hi';
</script>
<h1>{message</h1>Pass the test and this pattern moves unknown