Performance: ng-content for slot-based composition
MEDIUM IMPACT
This affects rendering speed and layout stability by controlling how content is projected into components.
<div> <ng-content select="[header]"></ng-content> <ng-content select="[main]"></ng-content> </div>
<div> <ng-content></ng-content> <ng-content></ng-content> </div>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Multiple unnamed ng-content | Duplicates projected nodes | Multiple reflows | High paint cost due to layout shifts | [X] Bad |
| Named ng-content slots with select | Projects nodes once correctly | Single reflow | Lower paint cost with stable layout | [OK] Good |