0
0
Vueframework~8 mins

v-model with select dropdowns in Vue - Performance & Optimization

Choose your learning style9 modes available
Performance: v-model with select dropdowns
MEDIUM IMPACT
This affects how quickly the dropdown updates the UI and how many DOM updates happen when the user selects an option.
Binding a select dropdown with many options and v-model
Vue
<template>
  <select v-model="selectedId">
    <option v-for="item in items" :key="item.id" :value="item.id">
      {{ item.name }}
    </option>
  </select>
</template>

<script setup>
import { ref, computed } from 'vue'
const selectedId = ref(null)
const items = ref(Array(1000).fill(0).map((_, i) => ({ id: i, name: `Item ${i}` })))
const selected = computed(() => items.value.find(item => item.id === selectedId.value))
</script>
Binding primitive values (like IDs) reduces reactivity overhead and avoids deep object comparisons.
📈 Performance GainImproves input responsiveness by reducing re-renders and memory usage.
Binding a select dropdown with many options and v-model
Vue
<template>
  <select v-model="selected">
    <option v-for="item in items" :key="item.id" :value="item">
      {{ item.name }}
    </option>
  </select>
</template>

<script setup>
import { ref } from 'vue'
const selected = ref(null)
const items = ref(Array(1000).fill(0).map((_, i) => ({ id: i, name: `Item ${i}` })))
</script>
Binding entire objects as option values causes Vue to do deep comparisons and triggers many re-renders on selection.
📉 Performance CostTriggers multiple re-renders and increases memory usage, slowing input responsiveness (INP).
Performance Comparison
PatternDOM OperationsReflowsPaint CostVerdict
Binding full objects as option valuesHigh (many reactive dependencies)Multiple reflows on selectionHigh paint cost due to re-renders[X] Bad
Binding primitive IDs as option valuesLow (simple reactive refs)Single reflow on selectionLow paint cost[OK] Good
Rendering Pipeline
When v-model updates on select change, Vue updates reactive state, triggers reactivity system, then updates DOM nodes for selected option.
Reactivity Update
Virtual DOM Diff
DOM Update
Paint
⚠️ BottleneckReactivity Update and Virtual DOM Diff when binding complex objects
Core Web Vital Affected
INP
This affects how quickly the dropdown updates the UI and how many DOM updates happen when the user selects an option.
Optimization Tips
1Bind primitive values (like IDs) in select options instead of full objects.
2Avoid complex reactive objects as v-model values to reduce re-renders.
3Use computed properties to map selected IDs back to objects if needed.
Performance Quiz - 3 Questions
Test your performance knowledge
What is the main performance issue when binding entire objects as option values in v-model select?
AVue does deep comparisons causing slow reactivity updates
BThe browser blocks rendering due to large CSS files
CThe select element triggers multiple network requests
DThe options are not accessible for screen readers
DevTools: Performance
How to check: Record a performance profile while selecting options in the dropdown. Look for long scripting or rendering tasks triggered by selection.
What to look for: Check for multiple re-renders or long scripting times indicating heavy reactivity or DOM updates.