Performance: Media queries
MEDIUM IMPACT
Media queries affect how CSS is applied based on device features, impacting rendering and layout recalculations during page load and resizing.
@media screen and (max-width: 600px) { .box { width: 100%; padding: 20px; } }
@media screen and (max-width: 600px) { .box { width: 100vw; } } @media screen and (max-width: 600px) { .box { padding: 20px; } }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Multiple separate media queries for same condition | Low | Multiple style recalculations | Moderate | [X] Bad |
| Combined media queries for same condition | Low | Single style recalculation | Low | [OK] Good |