Performance: Responsive typography scales
MEDIUM IMPACT
Responsive typography scales affect page load speed and rendering by controlling font size changes smoothly across devices without causing layout shifts.
$min-size: 1rem; $max-size: 1.25rem; $min-vw: 320; $max-vw: 1200; @function fluid-type($min, $max, $min-vw, $max-vw) { @return clamp(#{$min}, calc(#{$min} + (#{$max} - #{$min}) * ((100vw - #{$min-vw}px) / (#{$max-vw} - #{$min-vw}))), #{$max}); } body { font-size: fluid-type($min-size, $max-size, $min-vw, $max-vw); }
$font-size: 16px; body { font-size: $font-size; } @media (min-width: 768px) { body { font-size: 20px; } }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Abrupt font size changes at breakpoints | Minimal DOM changes | Multiple reflows on viewport resize | High paint cost due to layout shifts | [X] Bad |
| Fluid typography with clamp() or Sass calculations | Minimal DOM changes | Single reflow with smooth scaling | Low paint cost with stable layout | [OK] Good |