Repository navigation
Conversation
moylop260
force-pushed
the
scss-font-display-moy
branch
2 times, most recently
from
November 30, 2026 09:25
476c6e2 to
cb21345
Compare
… autofix A `@font-face` that serves its font as .otf, .ttf, .eot or .woff and no .woff2 makes every visitor download a bigger file than needed. WOFF2 compresses with Brotli: measured on 13 real fonts of Odoo 19.0 it is 44-72 % smaller than the .ttf/.otf (63 % in total) and 12-30 % smaller than the .woff (26 % in total). Every browser still supported reads it (Chrome 36, Firefox 39, Safari 12, Edge 14), so no other format is needed as a fallback. With the default font-display the text stays invisible while the font downloads, so its size shows in the paint metrics (GTmetrix: "Enormous network payloads"). The message explains how to convert the font without touching its glyphs. The autofix rewrites the url() and its format() when the .woff2 already sits next to the old file, keeping the quotes and the line endings; it does not convert the font, since that is a binary file that has to be reviewed. The stylesheets of the PDF report bundles (`report_assets_*`) are not reported: wkhtmltopdf renders them with an old QtWebKit that does not read WOFF2, and a PDF whose @font-face has only a .woff2 falls back to another font. The bundle is read from the "assets" of the manifest. This adds the scss checker: the hook now also runs on .scss and .css files, and reads the ones declared in the "assets" of the manifest.
moylop260
force-pushed
the
scss-font-display-moy
branch
from
November 30, 2026 09:28
cb21345 to
db54931
Compare
…th autofix A `@font-face` without `font-display` uses `auto`, which in practice is `block`: the text that uses the font stays invisible until the font arrives, up to 3 seconds, before the browser falls back (the flash of invisible text). That delays the First and Largest Contentful Paint of every page that has text in that font. GTmetrix reports it as "Ensure text remains visible during webfont load". `font-display: swap` paints the text at once with the fallback font and swaps it when the font is ready; `optional` is better for a decorative font because it never moves the text. The autofix adds `font-display: swap;` as the last declaration of the `@font-face`.
Collaborator
Author
|
Included in #207 as its first commit: the second check depends on the first one (same file, README and test counters), so both go in one PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
scss-font-display-missing: a@font-facewithoutfont-display.Depends on #205, which adds the scss checker; this PR contains its commit until it is merged, the new check is the last commit.
Why
Without
font-displaythe browser usesauto, which in practice isblock: the text that uses the font stays invisible while the font downloads, for a short block period (about 3 s in the browsers that implement it), before the browser falls back (the "flash of invisible text"). That delays the First and Largest Contentful Paint of every page that has text in that font. GTmetrix and Lighthouse report it as "Ensure text remains visible during webfont load".swapoptionalfallbackblockauto)Autofix
It adds
font-display: swap;as the last declaration of the@font-face, with the indentation of the previous declaration, the missing;of the last one when needed, and the line ending of the file (a file with CRLF stays with CRLF; a test caught that a first version inserted an LF).Report bundles
The stylesheets of the PDF report bundles (
report_assets_*) are not reported: wkhtmltopdf does not paint the text progressively, sofont-displayhas no effect there (see #205 for how the bundle is read).Tests
Full suite: 149 passed, 7 skipped. The fixture has 4 reported faces and 1 with
font-display, plus the report bundle that must stay untouched; 7 unit tests cover the one-line face, the missing;, case-insensitivefont-display, CRLF and the report bundle. README sections added by hand, as in #205.