Performance: GET, POST, PUT, DELETE handlers
MEDIUM IMPACT
This affects how fast the app responds to user actions and updates the UI by handling data requests efficiently.
import { writable } from 'svelte/store'; const dataStore = writable([]); async function fetchData() { const response = await fetch('/api/data'); const data = await response.json(); dataStore.set(data); } // Svelte updates DOM reactively, batching changes
async function fetchData() { const response = await fetch('/api/data'); const data = await response.json(); // directly update DOM elements manually here document.getElementById('list').innerHTML = data.map(item => `<li>${item.name}</li>`).join(''); } // called on every user action without debounce or batching
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Manual DOM updates on every fetch | Many direct DOM changes | Multiple reflows per update | High paint cost due to full list repaint | [X] Bad |
| Using Svelte reactive stores | Minimal DOM changes via diffing | Single reflow per update | Low paint cost, only changed nodes repainted | [OK] Good |