Self-hosting fonts: faster pages and one less privacy question
Browsers stopped sharing cached Google Fonts between sites in 2020, and a German court fined a site over them in 2022. Why serving fonts yourself is now the better default.
Loading fonts from Google Fonts used to come with a reasonable argument: so many sites used the same files that visitors probably had them cached already. That argument stopped being true years ago, and serving fonts from your own server is now faster, simpler and easier to defend.
The shared cache is gone
In October 2020, Chrome 86 began partitioning its HTTP cache. Cached files are now stored per site, keyed by the site that requested them as well as the file's address. A font cached while visiting one site is not reused on another. Safari had already partitioned its cache years earlier, and Firefox did the same.
Browser makers did this for privacy: a shared cache let one site detect whether you had visited another by timing how quickly a resource loaded. The side effect is that the main performance case for third-party font hosting disappeared.
Third-party fonts now cost time
Loading a font from another domain means the browser has to look up that domain, open a new connection and negotiate encryption before it can download anything. For Google Fonts that is usually two domains: one for the stylesheet and one for the font files. On a slow mobile connection those extra round trips show up directly in how quickly text appears.
Served from your own domain, the font arrives over the connection the browser already has open.
The privacy side
When a visitor's browser fetches a font from Google, Google receives the visitor's IP address. In January 2022, the Munich Regional Court ruled in case 3 O 17493/20 that a website had breached the GDPR by passing a visitor's IP address to Google through embedded Google Fonts without consent, and awarded the visitor 100 euros in damages.
The amount was small. What followed was not: thousands of templated demand letters were sent to German site owners citing the ruling. Self-hosting fonts removes the issue entirely, because no third party is contacted.
How to self-host well
- Download only what you use. Most sites need two or three weights, not the whole family.
- Use WOFF2. It is supported by every current browser and is the smallest format.
- Subset where you can. If the site is only in English, the Latin subset is enough.
- Set
font-display: swap, so text appears in a fallback font immediately instead of staying invisible while the font loads. - Preload the one or two fonts used above the fold, and no more. Preloading everything slows down what matters.
- Check the licence. Google Fonts are open source and may be self-hosted; commercial fonts often have conditions.
In Ironhelm
Fonts downloads the Google Fonts your theme and plugins request and serves them from your own server, rewriting the page so no visitor data goes to Google. Text appears straight away while fonts load.
Sources
- Chrome for Developers, Gaining security and privacy by partitioning the cache (2020)
- Landgericht München I, judgment of 20 January 2022, case 3 O 17493/20, summarised by the IHK Bergisches Land (in German)
- web.dev, Best practices for fonts
- MDN Web Docs, font-display
Ironhelm Suite is one WordPress plugin for security, speed, SEO and analytics. See plans or tour the features.