Performance: Options API vs Composition API decision
MEDIUM IMPACT
This affects initial page load speed and runtime rendering performance by influencing bundle size and reactivity system efficiency.
import { ref, onMounted } from 'vue'; export default { setup() { const count = ref(0); function increment() { count.value++; } onMounted(() => { console.log('Component mounted'); }); return { count, increment }; } }
export default { data() { return { count: 0 }; }, methods: { increment() { this.count++; } }, mounted() { console.log('Component mounted'); } }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Options API | Standard reactive bindings | Moderate reflows on state change | Moderate paint cost | [!] OK |
| Composition API | More granular reactive bindings | Fewer reflows due to optimized dependencies | Lower paint cost | [OK] Good |