0
0
Vueframework~8 mins

Dynamic render patterns in Vue - Performance & Optimization

Choose your learning style9 modes available
Performance: Dynamic render patterns
MEDIUM IMPACT
This affects how quickly the page updates and how smoothly user interactions feel when Vue dynamically renders or updates components.
Rendering a list with dynamic components that update frequently
Vue
<template>
  <div>
    <component
      v-for="item in items"
      :is="item.type"
      :key="item.id"
    />
  </div>
</template>

<script setup>
import { ref } from 'vue'
const items = ref([...])
// stable keys ensure Vue efficiently patches only changed items
</script>
Using stable :key enables Vue to diff the list efficiently and skip re-renders for unchanged items, reducing reflows.
📈 Performance Gainreduces reflows from N to only changed items, improving INP
Rendering a list with dynamic components that update frequently
Vue
<template>
  <div>
    <component v-for="item in items" :is="item.type" />
  </div>
</template>

<script setup>
import { ref } from 'vue'
const items = ref([...])
// items update frequently causing all components to re-render
</script>
Rendering dynamic components without stable keys on every update causes many reflows and repaints, slowing interaction.
📉 Performance Costtriggers N reflows per update where N is the number of items
Performance Comparison
PatternDOM OperationsReflowsPaint CostVerdict
Dynamic components without stable keyMany nodes updatedN reflows per updateHigh paint cost[X] Bad
Dynamic components with stable keyOnly changed nodes updatedMinimal reflowsLower paint cost[OK] Good
Rendering Pipeline
Dynamic render patterns cause Vue to patch the DOM frequently. This triggers style recalculation, layout, and paint stages in the browser.
Style Calculation
Layout
Paint
Composite
⚠️ BottleneckLayout is most expensive because dynamic updates often change element sizes or positions.
Core Web Vital Affected
INP
This affects how quickly the page updates and how smoothly user interactions feel when Vue dynamically renders or updates components.
Optimization Tips
1Avoid re-rendering all dynamic components on every data change.
2Use stable keys to minimize DOM updates.
3Profile layout events in DevTools to detect dynamic rendering bottlenecks.
Performance Quiz - 3 Questions
Test your performance knowledge
What is the main performance cost of rendering many dynamic components without stable keys in Vue?
AIncreased JavaScript bundle size
BFrequent layout recalculations causing slow interaction
CLonger initial page load time
DHigher network latency
DevTools: Performance
How to check: Record a performance profile while interacting with the dynamic list. Look for frequent Layout and Recalculate Style events.
What to look for: High number of layout events indicates inefficient dynamic rendering; fewer layout events means better performance.