Performance: Named slots
MEDIUM IMPACT
Named slots affect how content is distributed inside components, impacting rendering and layout stability.
<MyComponent> <div slot="header">Header content</div> <div slot="default">Default content</div> <div slot="footer">Footer content</div> </MyComponent>
<MyComponent> <div slot="header">Header content</div> <div slot="footer">Footer content</div> <div>Default content</div> </MyComponent>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Unnamed default slot mixed with named slots | Multiple nodes inserted dynamically | Multiple reflows on content change | Higher paint cost due to layout shifts | [X] Bad |
| Explicitly named slots including default | Stable node insertion | Single reflow on initial render | Lower paint cost with stable layout | [OK] Good |