Performance: Slots for content distribution
MEDIUM IMPACT
Slots affect how Vue distributes and renders child content inside components, impacting rendering speed and layout stability.
<MyComponent> <template v-slot:default> <ul> <li v-for="item in items" :key="item.id"> {{ item.text }} </li> </ul> </template> </MyComponent>
<MyComponent> <template v-slot:default> <div v-for="item in items" :key="item.id"> {{ item.text }} </div> </template> </MyComponent>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Unkeyed dynamic slot content with many elements | High (many nodes) | Multiple reflows per update | High paint cost | [X] Bad |
| Keyed slot content wrapped in semantic elements | Moderate (structured nodes) | Single reflow per update | Moderate paint cost | [OK] Good |