Performance: Why reactivity is Vue's core concept
HIGH IMPACT
Reactivity affects how quickly the UI updates in response to data changes, impacting interaction responsiveness and visual stability.
import { ref, watch } from 'vue'; const count = ref(0); watch(count, (newVal) => { // Vue updates DOM reactively and efficiently });
const data = { count: 0 }; function updateUI() { document.getElementById('count').textContent = data.count; } // Manually call updateUI() after every data change
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Manual DOM updates on data change | Many direct DOM writes | Multiple reflows per update | High paint cost due to full updates | [X] Bad |
| Vue reactive refs with watch | Minimal DOM writes via reactive system | Single reflow per batch | Low paint cost with targeted updates | [OK] Good |