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
- 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).
- 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.
- 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.
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
@font-faceentries 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).font-weight: 700and another atfont-weight: 600), or with text in more than one script/character subset.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