Performance: Dynamic components with is attribute
MEDIUM IMPACT
This affects rendering speed and responsiveness by controlling which component Vue renders dynamically.
<keep-alive> <component :is="currentComponent" /> </keep-alive> // Keeps inactive components cached to avoid full reloads
<component :is="currentComponent" /> // currentComponent changes frequently triggering full component reloads
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Dynamic component switch without caching | Destroys and recreates full component subtree | 1 reflow per switch | High paint cost due to full redraw | [X] Bad |
| Dynamic component switch with <keep-alive> | Reuses cached DOM nodes, minimal DOM changes | No reflows on cached switches | Low paint cost, only updates needed | [OK] Good |