--- url: "https://web.dev/articles/codelab-preload-web-fonts" titulek: "Preload web fonts to improve loading speed | Articles | web.dev" h1: "Preload web fonts to improve loading speed Stay organized with collections Save and categorize content based on your preferences." popis: "In this codelab, learn how to improve the performance of a page by preloading web fonts." jazyk: "en" kanonicka: "https://web.dev/articles/codelab-preload-web-fonts" drobecky: ["Articles", "Preload web fonts to improve loading speed"] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-13 23:11:53" znaku: 3208 slov: 472 kodovani: "iso-8859-2" sha256: "4017ce5e3b26cd131e05a5e7f2aa3b7975d5fc5d811a4eca9b7fea57be2d2a3b" --- Preload web fonts to improve loading speed Stay organized with collections Save and categorize content based on your preferences. Garima Mimani This codelab shows you how to preload web fonts using `rel="preload"` to remove any flash of unstyled text (FOUT). Measure First measure how the website performs before adding any optimizations. To preview the site, press **View App**. Then press **Fullscreen** . Press `Control+Shift+J` (or `Command+Option+J` on Mac) to open DevTools. Click the **Lighthouse** tab. Make sure the **Performance** checkbox is selected in the *Categories* list. Click the **Generate report** button. The Lighthouse report that is generated will show you the fetching sequence of resources under **Maximum critical path latency**. In the above audit the web fonts are part of the critical request chain and fetched last. The [**critical request chain**](https://developer.chrome.com/docs/lighthouse/performance/critical-request-chains) represents the order of resources that are prioritized and fetched by the browser. In this application, the web fonts (Pacfico and Pacifico-Bold) are defined using the [@font-face](/articles/font-best-practices#understanding_font-face) rule and are the last resource fetched by the browser in the critical request chain. Typically, webfonts are lazy loaded which means that they are not loaded until the critical resources are downloaded (CSS, JS). Here is the sequence of the resources fetched in the application: Preloading Web fonts To avoid FOUT, you can preload web fonts that are required immediately. Add the `Link` element for this application at the head of the document: `
` The `as="font" type="font/woff2"` attributes tell the browser to download this resource as a font and helps in prioritization of the reÂsource queue. The `crossorigin` attribute indicates whether the resource should be fetched with a CORS request as the font may come from a different domain. Without this attribute, the preloaded font is ignored by the browser. Since Pacifico-Bold is used in the page header, we added a preload tag to fetch it even sooner. It isn't important to preload the Pacifico.woff2 font because it styles the text that is below the fold. Reload the application and run lighthouse again. Check the **Maximum critical path latency** section. Notice how the `Pacifico-Bold.woff2` is removed from the critical request chain. It is fetched earlier in the application. With preload, the browser knows that it needs to download this file earlier. It is important to note that if not used correctly, preload can harm performance by making unnecessary requests for resources that are not used. Except as otherwise noted, the content of this page is licensed under the [Creative Commons Attribution 4.0 License](https://creativecommons.org/licenses/by/4.0/), and code samples are licensed under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0). For details, see the [Google Developers Site Policies](https://developers.google.com/site-policies). Java is a registered trademark of Oracle and/or its affiliates. Last updated 2018-04-23 UTC.