new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Vue · Guide · all subjects

performance

2 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

v-memo directive - memoize template sub-tree

v-memo memoizes a sub-tree of the template. Only supported in 3.2+. It expects a fixed-length array of dependency values to compare for memoization. Can be used on both elements and components. If every value in the array is the same as the last render, then updates for the entire sub-tree will be skipped. Even the Virtual DOM VNode creation will be skipped since the memoized copy of the sub-tree can be reused. It is important to specify the memoization array correctly to avoid skipping updates that should be applied. v-memo with an empty dependency array (v-memo="[]") is functionally equivalent to v-once.

v-memo with v-for for large lists

v-memo is provided for micro optimizations in performance-critical scenarios and should rarely be needed. When rendering large v-for lists (where length > 1000), v-memo can help. For example: <div v-for="item in list" :key="item.id" v-memo="[item.id === selected]"> only updates items that went from non-selected to selected or vice versa, allowing every unaffected item to reuse its previous VNode and skip diffing entirely. You don't need to include item.id in the memo dependency array since Vue automatically infers it from the item's :key. When using v-memo with v-for, ensure they are used on the same element - v-memo does not work inside v-for.

Give your agent this brain