Academy / Advanced Level: HTML and CSS

Web Performance Optimization

Optimizing Web Fonts

While custom web fonts improve the design of your website, they can also slow down your site’s performance if not optimized correctly.

Techniques for Optimizing Web Fonts:

  • Limit font weights and styles: Only load the font weights and styles you need.
  • Use font-display: swap: This ensures that text is displayed using a fallback font until the custom font is fully loaded, improving perceived performance.
@font-face {
font-family: 'MyFont';
src: url('myfont.woff2') format('woff2');
font-display: swap;
}
  • Use modern formats like WOFF2: Web Open Font Format 2 (WOFF2) offers better compression for faster loading.