How can you load a website’s fonts earlier?

ProcrustesPR

To load website fonts earlier, use preload so the browser can request fonts before it finishes downloading and parsing stylesheets. Another option is to inline render-blocking CSS containing @font-face declarations in the HTML head, allowing the browser to discover those declarations earlier. The key difference is that preload does not first check whether the page needs the font. Inline declarations, by contrast, trigger downloads only for fonts the current page needs, but those downloads must still wait for other render-blocking resources to load.

ProcrustesPRProcrustesPRHow should I divide my DIY SEO budget?

Request fonts earlier with preload, and do not omit crossorigin

To start downloading fonts without waiting for stylesheets to finish downloading and being parsed, set up a preload using a link element. The example provided by web.dev includes these settings:

  • rel=”preload”: Specifies that the resource should be preloaded.
  • as=”font”: Identifies the resource type as a font.
  • href: Points to the font file to load, such as /fonts/OpenSans-Regular-webfont.woff2.
  • crossorigin: Must be specified when preloading fonts, even if they are self-hosted, because fonts are CORS resources.

The browser starts downloading when it discovers the preload hint, without first checking whether the page needs the font. Before setting up a preload, confirm that the current page needs the specified file rather than adding every font to the list. Preloading too many fonts may download unused files and take bandwidth away from other critical resources.

Inlining @font-face: earlier discovery does not mean an immediate download

Another approach is to inline render-blocking CSS containing @font-face in a style element in the head. This lets the browser discover font declarations directly, without first downloading an external stylesheet. Unlike preload, this approach downloads only the fonts needed to render the current page, avoiding downloads of unused fonts.

However, discovering declarations earlier does not guarantee that font downloads will start immediately. According to the cited guidance, the browser must still wait for all render-blocking resources to load before downloading fonts this way. For example, if you move only @font-face into the head but leave the remaining render-blocking CSS in an external stylesheet, font downloads must still wait for that stylesheet to finish downloading. They cannot start early as they can with preload.

Inline font declarations, not font files

Inlining the font files themselves as Base64-encoded data in CSS or other resources is not recommended. The cited guidance notes that this increases the amount of data and may slow down the preload scanner, delaying the discovery of other critical resources. To help the browser discover fonts earlier through inlining, inline the @font-face declarations, not the contents of the font files.

ProcrustesPRProcrustesPRWhy can I not find my published article on Google?

Loading website fonts earlier: perspectives from across the web

If you know a page needs a particular font, how can you start downloading it without waiting for stylesheets?

Use preload for that font file so the browser can start downloading it before stylesheets finish downloading and being parsed. A preload hint does not first check whether the page needs the font, so it is suitable for files you have confirmed are needed. Preloading too many fonts may download unused fonts and take bandwidth away from other critical resources.

Will simply putting @font-face in the head make fonts download immediately?

Not necessarily. Inlining render-blocking CSS containing @font-face in the head allows the browser to discover font declarations earlier and download only the fonts the current page needs. However, if there is still an external render-blocking stylesheet, font downloads through this loading path must wait for that stylesheet to load.

Do self-hosted fonts also need crossorigin when preloaded?

Yes. The cited guidance states that fonts are CORS resources, so crossorigin must be specified when preloading fonts, even if the files are self-hosted.

Can embedding font files directly in CSS replace early loading?

This is not recommended. The cited guidance advises against inlining font files themselves in CSS or other resources because the Base64 encoding used by this approach increases the amount of data and may delay the preload scanner’s discovery of other critical resources. To help the browser discover fonts earlier through inlining, inline the @font-face declarations, not the contents of the font files.

ProcrustesPREight SEO essentials for beginners: Website speed

References

  1. Optimize web fontsweb.dev — Discusses: If you know a page needs a particular font, how can you start downloading it without waiting for stylesheets?; Will simply putting @font-face in the head make fonts download immediately?

Related articles

How should I divide my DIY SEO budget?Why can I not find my published article on Google?Eight SEO essentials for beginners: Website speedEight SEO essentials for beginners: Getting your pages indexedEight SEO essentials for beginners: Page titles and descriptionsThe Five Most Common Mistakes SEO Beginners MakeHow to Set Up Heading Tags for SEO: Define Topics and Hierarchy Before Adding KeywordsWhat are the benefits and development challenges of SPAs?
ProcrustesPR
ProcrustesPR