Two ways to use Google Fonts
Typography plays a huge part in how a website looks and feels. Google Fonts has become one of the most popular resources for designers and developers, with a vast library of free, open-source fonts that are easy to add to any site.
There are two ways to use them, and each has its own advantages and disadvantages. In this post we'll look at the pros and cons of self-hosting Google Fonts, to help you decide what's right for your next project.
Option 1: link to Google's servers
The quickest way is to add a <link> to your page's <head>. Google's servers then deliver both the CSS and the font files:
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap">
Option 2: self-host the fonts
Self-hosting means downloading the font files and serving them from your own website, alongside your images and CSS. You then load them with your own @font-face rules, and visitors' browsers never contact Google at all.
Pros of self-hosting
1. Better performance
When fonts come from Google, the browser has to connect to two extra servers (one for the CSS, one for the font files) before any text can appear in your chosen font. Self-hosted fonts come from the same server as the rest of your site, over a connection that's already open.
You also get full control over how they load. You can preload your most important font so it starts downloading straight away, and include only the weights and characters you actually use.
What about caching? It used to be said that Google-hosted fonts load instantly because visitors had probably already downloaded them on another site. That's no longer true: since around 2020, browsers keep a separate cache for each website, for privacy reasons. A font downloaded on one site is downloaded again on yours, wherever it's hosted.
2. Privacy
Each time a page loads fonts from Google, the visitor's browser sends a request to Google's servers, which includes their IP address. Self-hosting means no information about your visitors is shared with a third party just to show text.
This has legal weight in some places: in 2022, a court in Germany ruled that a website embedding Google Fonts had breached a visitor's privacy under the EU's data protection rules (GDPR) by passing on their IP address without consent. Self-hosting avoids the issue entirely.
3. Control and customisation
With the font files on your own server, you decide exactly which files you serve. You can subset a font (remove characters you don't need, such as alphabets for languages your site doesn't use) to make the files smaller, and choose the formats and weights that suit your design.
Most Google Fonts use the SIL Open Font License, which also allows you to modify the fonts themselves. If you do, check the licence: some fonts ask that modified versions are given a different name.
4. No dependence on another company's servers
Your fonts keep working even if Google's font service is slow, blocked in a visitor's country or network, or changes how it works. Everything your site needs comes from one place: your own server.
Cons of self-hosting
1. A little more setup
Self-hosting takes a few extra steps: downloading the font files, uploading them to your server and writing the @font-face rules. That can feel daunting if you're just starting out.
To make it easier, we've built a tool that downloads all the font files and creates the CSS for you. Find our self-hosting Google Fonts tool here.
2. Updates are up to you
Google occasionally updates fonts, for example adding characters or fixing spacing. When you self-host, your files don't update automatically, so you'll need to download new versions yourself if you want the changes. For most sites, fonts rarely need updating, so this is a small job.
3. Bandwidth and storage
Font files are served from your own hosting, so they use some of your bandwidth and storage. In practice, a modern WOFF2 font file is usually only tens of kilobytes, so for most sites the cost is tiny. On a very busy site, it's worth keeping the number of font files small.
4. Keep the licence
Every font on Google Fonts is released under an open-source licence (mostly the SIL Open Font License, with a few under the Apache License), so all of them can be self-hosted for free, including on commercial websites. The main requirement is simple: keep a copy of the font's licence file alongside the font files.
5. Choosing the right formats
Google's service used to send each browser a different font format, which was a real advantage when browsers disagreed on formats. Today, the WOFF2 format works in every modern browser, so self-hosted sites only need one file per font style. This is no longer the drawback it once was.
Side-by-side comparison
| Google's servers | Self-hosted | |
|---|---|---|
| Setup | Copy one <link> tag | Download files and write @font-face rules, or use a generator |
| Speed | Extra connections to Google's servers | Same connection as your site; can be preloaded |
| Privacy | Visitors' IP addresses are sent to Google | Nothing is shared with a third party |
| Control | Limited to Google's options | Full control over files, subsets and loading |
| Updates | Automatic | Manual, when you choose |
| Reliability | Depends on Google's service | Depends only on your own server |
| Cost | Free | Free; uses a little of your hosting bandwidth |
How to self-host Google Fonts
Self-hosting takes just a few steps:
- Download the files. Use our Google Fonts CSS Generator to choose a font and its weights, and download the WOFF2 files along with ready-made CSS.
- Upload them to a folder on your site, such as
/fonts/, together with the licence file. - Add the CSS. Each weight and style gets its own
@font-facerule:
@font-face {
font-family: "Inter";
src: url("/fonts/inter-400.woff2") format("woff2");
font-weight: 400;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: "Inter";
src: url("/fonts/inter-700.woff2") format("woff2");
font-weight: 700;
font-style: normal;
font-display: swap;
}
body {
font-family: "Inter", system-ui, sans-serif;
}
- Preload your main font (optional, but it speeds things up), by adding this to your page's
<head>:
<link rel="preload" href="/fonts/inter-400.woff2" as="font" type="font/woff2" crossorigin>
- Remove the old Google Fonts link from your pages, so the fonts aren't loaded twice.
Tip: font-display: swap shows your text straight away in a backup font, then swaps in the custom font once it has loaded, so visitors never stare at blank space. The crossorigin attribute on the preload link is required for fonts, even on your own site, or the browser will download the file twice.
Which should you choose?
It depends on your project:
- Choose self-hosting if privacy matters (especially for visitors in Europe), if you want the best loading speed, or if you'd like full control over your fonts. For most professional websites, it's now the recommended approach.
- Choose Google's servers for quick prototypes, personal projects or situations where the simplest possible setup matters most.
Either way, our Google Fonts CSS Generator can help: it creates the code to link to Google's servers, or downloads the font files and CSS you need to self-host.
Wrapping up
Self-hosting Google Fonts gives you faster loading, better privacy and full control, in exchange for a few minutes of setup and the occasional manual update. With a generator to do the hard work, the trade-off is well worth it for most websites.