Performance: Why form binding matters
MEDIUM IMPACT
Form binding affects how quickly user input updates the UI and how efficiently the browser handles DOM updates during interaction.
<template> <input v-model="formValue" aria-label="User input" /> <p>{{ formValue }}</p> </template> <script setup> import { ref } from 'vue' const formValue = ref('') </script>
<template> <input :value="formValue" @input="updateValue" /> <p>{{ formValue }}</p> </template> <script setup> import { ref } from 'vue' const formValue = ref('') function updateValue(event) { formValue.value = event.target.value } </script>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Manual input event handling | Multiple updates per keystroke | Triggers reflow on each update | Higher paint cost due to frequent changes | [X] Bad |
| Vue v-model binding | Single reactive update per keystroke | Minimal reflows due to optimized patching | Lower paint cost with batched updates | [OK] Good |