𝗜 𝗦𝘁𝗼𝗽𝗽𝗲𝗱 𝗨𝘀𝗶𝗻𝗴 𝗚𝗼𝗼𝗴𝗹𝗲 𝗙𝗼𝗻𝘁𝘀 𝗖𝗗𝗡

Loading fonts from a Google CDN slows down your site.

I used to use a single link in my header. It felt easy. Then I checked my Lighthouse scores.

The report showed a problem. The browser had to make extra connections to Google's servers. It had to perform DNS lookups and TLS handshakes. This caused delays. On a slow mobile connection, the text stayed invisible for too long.

I switched to self-hosting. It took one afternoon. Now I do it for every project.

Here is the setup you need:

The workflow is simple: Convert to WOFF2. Use @font-face with swap. Preload the main font with crossorigin. Cache the file.

This setup improves your loading speed and removes a third party from your critical path.

Do you still use the Google CDN for production? Tell me why in the comments.

Source: https://dev.to/fontbox/i-stopped-loading-fonts-from-googles-cdn-heres-the-self-hosting-setup-that-stuck-2lpm