Memoization Techniques
Avoid redundant computation with memoization.
Doing Less Work
Performance often comes from not recomputing or re-rendering things that have not changed. Vue gives you several memoization tools that cache results and skip unnecessary updates.
Computed Caching
A computed property caches its result and only recalculates when one of its reactive dependencies changes. This makes it far cheaper than a method that runs on every render.
computed: {
expensiveTotal() {
return this.items.reduce((sum, i) => sum + i.price, 0)
}
}All lessons in this course
- Lazy Loading and Code Splitting
- Memoization Techniques
- Identifying and Fixing Bottlenecks