Back
VueHardNew
What common performance optimization techniques are used in large Vue 3 applications?
Lazy loading, v-memo, shallowRef, virtualization
Ideal Answer
Common performance techniques in production Vue 3 apps:
- Route/component lazy loading (
() => import(...)) to reduce initial bundle size. v-once/v-memoto skip re-rendering static or infrequently changing subtrees.shallowRef/shallowReactivefor large data structures that don't need deep reactivity.- List virtualization (e.g., via
vue-virtual-scroller) for rendering very large lists efficiently. v-showvsv-ifchosen deliberately based on toggle frequency.KeepAliveto avoid re-mounting components with expensive setup.- Debouncing/throttling expensive watchers or event handlers (often via VueUse composables).
- Using the
<script setup>compiler optimizations, which generate more efficient render code than manualsetup()returns.