Skip to content

[css-fonts] More intuitive version of preload + font-display optional #5924

@xiaochengh

Description

@xiaochengh

When a web author doesn't want to pay any CLS for web fonts, but still want the font to be used with a big enough chance, there's a trick of combining (example example):

  • A preload of the font file (<link rel=preload>)
  • Setting the font-display descriptor value to optional

It makes the web font acts similar to a local font that:

  • If the font loads fast enough, then we never use fallback fonts, which is similar to a successful load of a local font
  • If the font loads slow to fails, then we end up using fallback, which is similar to a failed load of a local font

However, the trick is pretty unintuitive. Preload indicates that the font is important, yet font-display: optional means the font is not so important. It can be very confusing (example).

So I'm filing this issue to investigate a more intuitive version.


Idea: A new font-display value that does the same? As soon as we see it in a stylesheet, we kick off a preload of the font, and block rendering before the preload finishes or a timeout (e.g., 50ms); And the font enters the failure font display period as long as any fallback has been used.

Also note that in Chrome, we've already implemented this behavior when preloading and font-display: optional are used together.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions