--- url: "https://web.dev/learn/performance/optimize-web-fonts" titulek: "Optimize web fonts | web.dev" h1: "Optimize web fonts Stay organized with collections Save and categorize content based on your preferences." popis: "Web fonts are a commonly used resource on the web—and rightfully so—as they add to the design of a website in ways that other resources can't. Even so, web fonts still have a performance cost. In this module, a number of performance considerations and techniques around web fonts are explored." jazyk: "en" kanonicka: "https://web.dev/learn/performance/optimize-web-fonts" drobecky: ["web.dev", "Resources", "Performance"] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-13 23:13:29" znaku: 11489 slov: 1740 kodovani: "iso-8859-2" sha256: "1c48908a72eefecb881bde1530925b15c3bb7c29592c757c2bc719ee094290cb" --- Optimize web fonts Stay organized with collections Save and categorize content based on your preferences. In the previous modules, you learned how to optimize HTML, CSS, JavaScript, and media resources. In this module, discover some methods to optimize web fonts. Web fonts can impact page performance at both load time and rendering time. Large font files can take a while to download and negatively affect [First Contentful Paint (FCP)](/articles/fcp), while the incorrect [`font-display` value](https://developer.mozilla.org/docs/Web/CSS/@font-face/font-display) could cause undesirable visual rendering shifts. Before optimizing web fonts can be discussed, knowing how they're discovered by the browser can be helpful, so that you can understand how CSS prevents the retrieval of unnecessary web fonts in certain situations. Discovery A page's web fonts are defined in a style sheet using a `@font-face` declaration: `@font-face { font-family: "Open Sans"; src: url("/fonts/OpenSans-Regular-webfont.woff2") format("woff2"); }` The preceding code snippet defines a `font-family` named `"Open Sans"`, and tells the browser where to find the respective web font resource. To conserve bandwidth, the browser does not download the web font until it is determined that the current page's layout needs it. `h1 { font-family: "Open Sans"; }` In the preceding CSS snippet, the browser downloads the `"Open Sans"` font file as it parses an `

` element in the page's HTML. `preload` If your `@font-face` declarations are defined in an external style sheet, the browser can only begin downloading them after it has downloaded the style sheet. This makes web fonts late-discovered resources—but there are ways to help the browser discover web fonts sooner. You can initiate an early request for web font resources by using the `preload` directive. The `preload` directive makes web fonts discoverable early during page load, and the browser immediately begins downloading them without waiting for the style sheet to finish downloading and parsing. The `preload` directive does not wait until the font is needed on the page. ` ` Inline `@font-face` declarations You can make fonts discoverable earlier during page load by inlining render-blocking CSS—including the `@font-face` declarations—in the `` of your HTML using the [`