I'm revamping our company site and finally moving away from system fonts. I want to use a custom font family from Google Fonts, but I'm worried about screwing up the performance. I've heard horror stories about FOIT/FOUT and layout shift. What's the current robust method to implement how to use web fonts properly? Do I just use the link tag they provide, or is there a better approach with font-display or self-hosting to control loading behavior and avoid those flashes of invisible text?
For more control, especially on critical sites, consider self-hosting your chosen fonts. This lets you host WOFF2 files (the most efficient format) on your own CDN, reducing third-party dependencies and giving you full control over caching headers. The key steps are: legally license/download the font files, convert them to WOFF2, use a @font-face rule in your CSS with font-display: swap, and preload the most critical font file in your HTML. Also, define a proper font stack in your CSS so the fallback system font is visually and metrically similar, reducing layout shift. For a comprehensive, step-by-step guide that walks through all these methods, optimization techniques, and code examples, this resource on how to use web fonts https://clay.global/blog/web-design-guide/web-fonts is excellent. It covers the nuances from selection to implementation.