Performance: Role of CSS in web development
MEDIUM IMPACT
CSS affects how fast the page looks styled and how smoothly it responds to user actions.
body, div, p { font-size: 16px; }body { font-size: 16px; } div { font-size: 16px; } p { font-size: 16px; }| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Repeating styles for many selectors | Low | Low | Low | [!] OK |
| Combining selectors to reduce repetition | Low | Low | Low | [OK] Good |
| Using deep complex selectors | Low | Medium | Medium | [X] Bad |
| Using simple class selectors | Low | Low | Low | [OK] Good |