
Similar to block, this value should only be used when rendering text in a particular font is important for the page font-display: swap shows the font as soon as it loads.Use this value when the font is important for the page In other words, it always swaps in the web font when it loads. font-display: block gives the font a 3s (in most cases) short block period and an infinite swap period.font-display: auto uses whatever font display strategy the user-agent uses.Understanding these periods will allow you to use the font-display values more effectively: If the font is not yet loaded when this period starts, it’s marked as a failed load, causing normal font fallback. The font failure period occurs immediately after the font swap period.
If the font-face successfully loads during this period, the font is then used normally.
If the font-face is not loaded during this period, any element attempting to use it must instead render with a fallback (system) font (FOUT). The font swap period occurs immediately after the font block period.
If the font-face successfully loads during this first period, it is then used normally. If the font-face is not loaded during this period, any element attempting to use it must instead render with an invisible fallback font face (FOIT).
The first period is the font block period. The process of font downloading is divided into three major periods: It is defined per font-face.īrowsers have default font-loading behavior when rendering text that uses a font-family that is not yet available: Then, the font-display property was announced.įont-display tells the browser how it should proceed with text rendering when the associated web font has not loaded. Put simply, you could either make your visitors stare at a blank screen or risk unexpected layout shifts occurring on your website.īoth are unacceptable solutions in today’s Core Web Vitals world.īasically, the font loading situation was: Flash of Unstyled Text (FOUT) uses the fallback system font initially and then upgrades to the web font when it downloads. Flash of Invisible Text (FOIT) where the text is hidden until the font is downloaded. And all of the current strategies for serving web fonts have significant drawbacks.įor quite some time, if you wanted to serve web fonts, you had to choose between: Font loading has been a big culprit of web performance for years now. That might be a bit harsh, but it’s the truth. There is not a single font optimization technique that can solve all of your problems. What You Should Know about Font Loading (In a Nutshell) In the following lines, we’ll see how fonts affect your Core Web Vitals and how you can optimize their loading. And web fonts are the ones making all these things possible. Typography is also fundamental to good design, branding, readability, and accessibility. However, there is another player that shouldn’t be overlooked - web fonts.Ĭonsidering that they are often large files that take a while to load and can even block rendering of the text, font optimization is a critical piece of the overall performance strategy. When we talk about web performance and especially the Core Web Vitals (CWV), it almost seems like image and JavaScript optimization techniques steal the spotlight. Originally was published in October 2021 and has been updated for comprehensiveness in October 2022