Performance: Clamp function
LOW IMPACT
The clamp() function affects layout and paint by providing responsive sizing without extra media queries.
h1 {
font-size: clamp(1rem, 2vw, 1.5rem);
}h1 {
font-size: 16px;
}
@media (min-width: 600px) {
h1 {
font-size: 20px;
}
}
@media (min-width: 900px) {
h1 {
font-size: 24px;
}
}| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Multiple media queries for font size | Minimal | Multiple on resize | Moderate | [X] Bad |
| Single clamp() function for font size | Minimal | Single on resize | Low | [OK] Good |