Performance: Async components for lazy loading
HIGH IMPACT
This affects the initial page load speed by deferring component loading until needed, improving time to interactive.
import { defineAsyncComponent } from 'vue'; export default { components: { LargeComponent: defineAsyncComponent(() => import('./LargeComponent.vue')) } };
import LargeComponent from './LargeComponent.vue'; export default { components: { LargeComponent } };
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Eager import of large component | High upfront DOM nodes | Multiple reflows during initial load | High paint cost due to large bundle | [X] Bad |
| Async component lazy loaded | DOM nodes added on demand | Single reflow when component loads | Lower initial paint cost | [OK] Good |