Vue performance optimization spans bundle size, rendering efficiency, and reactivity cost. Here are the highest-impact techniques.
1. Code splitting / lazy loading
routes = [{ : , : () }];
= ( ());
Vue performance optimization spans bundle size, rendering efficiency, and reactivity cost. Here are the highest-impact techniques.
routes = [{ : , : () }];
= ( ());
The biggest initial-load win: don't ship code the user doesn't need yet.
<div v-show="tab === 'a'"> <!-- toggled often → cheap CSS flip -->
<div v-if="rarelyShown"> <!-- rarely rendered → skip building it -->
<li v-for="item in items" :key="item.id"> <!-- enables efficient DOM reuse/diffing -->
import { shallowRef, shallowReactive } from "vue";
// for large objects you replace wholesale (or 3rd-party instances), skip deep tracking
const bigData = shallowRef(hugeObject); // only .value reassignment is reactive
Object.freeze(staticConfig); // never-changing data → no reactivity overhead
Deep reactivity on huge objects is costly; shallowRef/shallowReactive/Object.freeze avoid tracking data that doesn't need it.
<p>{{ expensiveComputed }}</p> <!-- cached, recomputes only on dependency change -->
<header v-once>{{ siteName }}</header> <!-- render once, never update -->
<div v-memo="[item.id]">...</div> <!-- re-render only if item.id changes -->
Rendering 10,000 rows kills performance → use vue-virtual-scroller / TanStack Virtual
to render only the visible rows.
Vue DevTools (component render timings, why a component re-rendered)
build output / rollup-plugin-visualizer → bundle composition
Lighthouse → Core Web Vitals
Vue is fast by default, but large apps need deliberate optimization: lazy-load to shrink bundles, choose v-if/v-show correctly, use stable keys, avoid over-reactivity on big data (shallowRef/freeze), cache with computed/v-memo, and virtualize long lists.
Knowing which technique addresses which bottleneck — and measuring with DevTools/Lighthouse rather than guessing — is what keeps a growing Vue app responsive.
A library of IT interview questions with detailed answers — from Junior to Senior.
Donate