Performance: JavaScript expressions in templates
MEDIUM IMPACT
This affects rendering speed and responsiveness by how often expressions are evaluated and how complex they are inside Vue templates.
<script setup> import { computed } from 'vue' const activeCount = computed(() => items.filter(item => item.active).length) </script> <template> <div>{{ activeCount }}</div> </template>
<template>
<div>{{ items.filter(item => item.active).length }}</div>
</template>| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Complex inline expressions | Multiple recalculations | Multiple reflows if DOM changes | High paint cost due to frequent updates | [X] Bad |
| Computed properties for logic | Minimal recalculations | Single reflow per change | Lower paint cost with fewer updates | [OK] Good |