Skip to content

new_audit(fonts): recommend serving fonts as WOFF2 - #17152

Open
filchakov wants to merge 2 commits into
GoogleChrome:mainfrom
filchakov:modern-font-formats-audit
Open

new_audit(fonts): recommend serving fonts as WOFF2#17152
filchakov wants to merge 2 commits into
GoogleChrome:mainfrom
filchakov:modern-font-formats-audit

Conversation

@filchakov

Copy link
Copy Markdown
Contributor

Summary

Adds a new modern-font-formats byte-efficiency audit that recommends serving loaded TTF, OTF, and WOFF fonts as WOFF2.

The audit:

  • inspects loaded font network requests;
  • detects legacy formats using the MIME type first, with the URL extension as a fallback for generic or missing MIME types;
  • excludes WOFF2 and non-font resources;
  • reports the URL, detected format, transfer size, and estimated byte savings;
  • deduplicates repeated requests by URL;
  • reports an opportunity when the aggregate estimated savings are at least 4 KiB;
  • is included in the default config as a zero-weight diagnostic.

Motivation

The Web Almanac 2025 Fonts chapter reports that WOFF, TTF, and OTF are still used for a meaningful share of font requests:

  • WOFF: 16.0% desktop / 15.8% mobile
  • TTF: 6.7% desktop / 6.8% mobile
  • OTF is also present in hundreds of thousands of requests in the published dataset

WOFF2 can reduce font transfer sizes without changing the font's functionality. This audit makes that opportunity visible and actionable in Lighthouse without downloading font response bodies or performing conversions during a
run.

Estimated savings

Savings are based on the paired original, WOFF1, and WOFF2 sizes published in the W3C WOFF 2.0 Evaluation Report.

For TTF and OTF, the estimate is calculated per font as:

(originalBytes - woff2Bytes) / originalBytes

The audit then uses the corpus median:

- TTF: 62.12%, using the lower TrueType corpus median
- OTF: 49.69%, using the Adobe CFF corpus as a network-level proxy for CFF-based OTF fonts
- WOFF: 13.51%, using the lower WOFF2-over-WOFF1 median

The WOFF coefficient is deliberately conservative. The report gives medians of 23.94% for the Google TrueType corpus, 26.79% for the Adobe TrueType corpus, and 13.51% for the Adobe CFF corpus. A network record does not reveal
the outline type inside a WOFF file, so the lower CFF value avoids overstating potential savings.

As a manual validation, converting a 67,328-byte Open Sans WOFF file to WOFF2 produced a 50,056-byte file, saving 17,272 bytes (25.65%). The audit conservatively estimates 9,096 bytes (13.51%) for the same resource.

Testing

Added unit coverage for:

  • TTF, OTF, and WOFF savings estimates
  • canonical and legacy MIME types
  • mixed-case and parameterized MIME types
  • WOFF2 MIME aliases
  • MIME precedence over misleading extensions
  • URL-extension fallback
  • unknown formats and non-font resources
  • aggregate savings threshold boundaries
  • multiple small font requests
  • cached resources with missing or zero transfer sizes
  • duplicate URLs

Added end-to-end coverage to the existing perf-fonts smoke fixture using a loaded TTF font.

Validation completed:

  • yarn lint --fix
  • yarn type-check
  • yarn update:sample-json
  • relevant audit, config, i18n, and sample JSON tests — 82 passing
  • yarn smoke perf-fonts — 6 assertions passing
  • git diff --check

Related Issues/PRs

Related to #16543.

@filchakov
filchakov requested a review from a team as a code owner July 31, 2026 00:05
@filchakov
filchakov requested review from paulirish and removed request for a team July 31, 2026 00:05
@filchakov

Copy link
Copy Markdown
Contributor Author

Hi @connorjclark,

Whenever you have some free time, would you mind reviewing this quick PR for issue #16543?
I’d really appreciate your feedback.
Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant