Performance: Why advanced reactivity matters
HIGH IMPACT
This affects how fast the page updates when data changes, impacting user interaction smoothness and rendering speed.
const count = ref(0); const items = ref([]); watch(count, () => { // only runs when count changes efficientUpdate(); });
const state = reactive({ count: 0, items: [] }); watch(state, () => { // runs on any change, even unrelated expensiveUpdate(); });
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Watching entire reactive object | High (many nodes affected) | Multiple reflows per unrelated change | High paint cost due to frequent updates | [X] Bad |
| Watching specific refs or computed | Low (only affected nodes) | Single reflow per relevant change | Low paint cost with minimal updates | [OK] Good |