Performance: Computed vs method performance
MEDIUM IMPACT
This affects how fast Vue updates and renders reactive data on the page during user interaction.
export default { data() { return { count: 0 }; }, computed: { doubled() { return this.count * 2; } } }
export default { data() { return { count: 0 }; }, methods: { doubled() { return this.count * 2; } } }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Method for reactive value | No extra DOM nodes | Multiple recalculations trigger more JS work | Normal paint cost | [X] Bad |
| Computed property for reactive value | No extra DOM nodes | Recalculates only on dependency change | Normal paint cost | [OK] Good |