Under The Hood
frontend vue Vue 3.2+

Vue v-memo: skipping DOM patch work

Last updated
Prerequisites:
Vue template basics
Basic understanding of the virtual DOM patch process
  • vue
  • v-memo
  • rendering
  • virtual-dom
  • patch
  • performance

Read at your depth

The practical view

v-memo="[deps]" tells Vue: if every value in the deps array is identical (Object.is) since the last render, reuse the rendered virtual nodes of this block and skip the diff/patch entirely. Typical usage: v-for with v-memo="[item.id, item.updatedAt]" so a row only re-renders when its own data changed: <div v-for="item in items" :key="item.id" v-memo="[item.id, item.updatedAt]">. The deps array is compared with shallow equality against the previous render's values. When a dependency changes, the whole block re-renders and the memo caches the new values.

The same idea in other frameworks

react equivalent
// memo() on the row component compares props shallowly
const Row = memo(RowView);
// or skip work in the parent with useMemo for the list

Legacy vs modern

Large list without v-memo vs with v-memo

Without v-memo every render re-diffs all rows; with v-memo each row costs one shallow compare of its memo deps when nothing changed.

before → after
Full re-diff
<div v-for="item in items" :key="item.id"> <!-- ❌ OLD: no v-memo → every row re-diffs each tick -->
  <p>{{ item.title }}</p>
</div>
v-memo per row
<div v-for="item in items" :key="item.id"
     v-memo="[item.id, item.likes]" <!-- NEW: skip patch when [id, likes] unchanged -->
  <p>{{ item.title }}</p>
</div>

Interview gotchas

Under The Hood — a multi-depth technical interview hub.

Press ⌘ K to search.