Skip to content

Above-the-fold font preload detection misses/misattributes font files #8827

Description

@DahmaniAdame

Above-the-fold font preload detection misses/misattributes font files when a family has more than one weight, style, stretch, or character subset in use

Critical fonts only reports a single font file per font-family found above the fold. On any page where the same family is rendered above the fold with more than one weight, style, width (font-stretch), or character subset (unicode-range), detection is incomplete and can attribute the wrong file to the wrong element entirely.

Steps to reproduce

  1. Use a page where a font-family is declared with multiple @font-face entries that differ by weight and/or style (self-hosted fonts and services like Google Fonts both commonly do this; Google Fonts additionally splits most families into several files by character subset even for a single weight/style).
  2. Render at least two elements above the fold that use that same font-family but at different weights (e.g. a heading at font-weight: 700 and another at font-weight: 600), or with text in more than one script/character subset.
  3. Run the beacon and inspect the fonts it recommends preloading.

Expected behavior

Every font file genuinely required to render the above-the-fold content should be detected, each correctly attributed to the element(s) that actually use it.

Acceptance criteria

  • Fonts matching criteria should include font-weight, font-style, font-stretch (condensed/expanded/normal width), and unicode-range (character-subset) together as one combined match.
  • All qualifying unique font files above the fold are reported, not just the first match.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: preload fontspriority: mediumIssues which are important, but no one will go out of business.severity: moderateFeature isn't working as expected but has work around to get same valuetype: enhancementImprovements that slightly enhance existing functionality and are fast to implement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions