Sub topic 3
Loading the Right Web Font Resources
Assume you know basic HTML, CSS selectors, font-family, and browser developer tools. This chapter focuses on reducing font downloads while keeping text readable during loading.
Load only needed weights and styles
A font weight is the thickness of a font. If a page uses regular text and bold headings, request only weights 400 and 700. Do not load italic, light, or extra weights unless the design uses them.
A variable font stores a range of values in one font file. For example, one file can support weights from 100 to 900. It can reduce the number of files, but the file may still be larger than a single static weight.
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">Use the variable range when the design needs several weights:
h1 {
font-family: "Inter", system-ui, sans-serif;
font-weight: 650;
}Loading behavior and layout shifts
font-display: swap shows a fallback font immediately, then replaces it when the web font arrives. This avoids invisible text, but different font metrics can move nearby content. Choose a fallback with similar proportions, or tune it with size-adjust in an @font-face rule.
A preconnect hint starts the connection to an external font host early. Use it only for hosts the page actually contacts.
Pairing fonts
Pair a distinctive heading font with a calmer body font. Check contrast in shape, not just difference. Test headings, paragraphs, buttons, and numbers at realistic sizes. Confirm that both fonts support the languages your site needs.
Self-hosting and privacy
Self-hosting stores font files on your domain. It avoids a visitor’s browser contacting Google or Adobe, which can help with privacy and predictable availability. You must track licenses, serve efficient WOFF2 files, and update the files yourself.
Choosing a service
| Need | Better fit |
|---|---|
| Open catalog and simple project setup | Google Fonts |
| Adobe library or Creative Cloud workflow | Adobe Fonts |
| Maximum control over requests and caching | Self-hosted files |
Google Fonts commonly offers openly licensed families. Adobe Fonts requires an eligible Adobe plan and an active web project. Check the current license and account terms before shipping.
> callout note > Test font loading on a slow connection. A page that looks stable on a fast developer connection may shift noticeably for real users.
Exercise
A page uses weights 400 and 700 but requests 100–900. What should you change?
Show answer
Request only 400 and 700, unless the design genuinely needs other weights. Use a variable range only when intermediate weights are required.