Performance: Text interpolation with mustache syntax
MEDIUM IMPACT
This affects the rendering speed of dynamic text content in the browser and how often the DOM updates when data changes.
<template>
<div>{{ result }}</div>
</template>
<script setup>
import { ref, computed } from 'vue'
const data = ref(10)
const result = computed(() => {
// heavy computation only runs when data changes
return `Result: ${data.value}`;
})
</script><template>
<div>{{ complexFunction() }}</div>
</template>
<script setup>
function complexFunction() {
// heavy computation or side effects
return 'Result';
}
</script>| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Direct function call in mustache | Updates text node every render | Triggers reflow each update | Paints text changes frequently | [X] Bad |
| Computed property in mustache | Updates text node only on data change | Minimal reflows triggered | Paints only when necessary | [OK] Good |