Description
Font loading is one of the largest contributors to Largest Contentful Paint (LCP) on real websites. Peakspire Font Loading Optimizer applies the three highest-impact font fixes, built from hands-on Core Web Vitals engineering on production sites:
-
Preload local WOFF2 fonts – Scans your enqueued stylesheets for locally hosted WOFF2 files and adds
<link rel="preload">tags, capped at 4 fonts. Preloaded fonts arrive before the browser discovers them inside CSS files, removing the font round-trip from the critical path. -
Adds
font-display: swapto eligible inline@font-facerules – Rules that already declare an explicitoptional,block,fallback, orautovalue are never touched. Rules without a descriptor getswap, so text renders immediately with the fallback font instead of sitting invisible while web fonts download. -
Remove external Google Fonts (optional) – Dequeues all fonts.googleapis.com requests for sites that have self-hosted their fonts.
-
Remove dashicons for visitors (optional) – Dequeues the dashicons stylesheet for logged-out visitors, saving a render-blocking request most themes never use on the front end.
Everything is front-end only and safe to use alongside caching plugins (WP Rocket, LiteSpeed Cache, W3 Total Cache, etc.).
Why only local fonts are preloaded
Cross-origin font preloads waste bandwidth when the crossorigin fetch does not match the stylesheet fetch. This plugin deliberately preloads only same-host WOFF2 files, the safe default for virtually all themes that self-host fonts.
Installation
- Upload the
peakspire-font-loadingfolder to/wp-content/plugins/, or install via the Plugins screen. - Activate the plugin.
- Open Settings Peakspire Font Loading Optimizer. Preload and font-display are on by default; both are recommended.
FAQ
-
Which fonts does this preload?
-
WOFF2 files hosted on your own domain that are referenced from enqueued external stylesheets, up to a static maximum of 4 per page. Fonts declared inline in the HTML head are deliberately NOT preloaded: the browser already discovers those at parse time, so preloading them adds bandwidth cost without benefit (measured: a ~0.9s LCP regression on an inline-declaring theme before this rule was enforced). This is a deliberate simplicity tradeoff: the plugin does not measure per-page font relevance (paid performance suites do). For most sites with 2-4 font families, the cap is the right size.
-
Does this replace a font-localization plugin like OMGF?
-
No – it complements one. Localization plugins handle fonts sourced from Google/Bunny CDNs. This plugin handles the other half: the fonts your theme or builder already bundles locally. Use both if you have both.
-
Does this work with caching plugins?
-
Yes. All changes are front-end output (preload tags and CSS descriptor injection). Nothing modifies your theme files or cache behavior.
-
Which fonts get preloaded?
-
Only WOFF2 files hosted on your own domain that are referenced from your enqueued stylesheets, up to a maximum of 4. Preloading more fonts typically hurts more than it helps.
-
What if my fonts come from Google Fonts?
-
Enable the “Remove external Google Fonts” option only after self-hosting your fonts. Sites not ready for that step should leave it off.
-
Is the font-display change safe for my design?
-
font-display: swap shows the fallback font until your web font loads, then swaps. It is the descriptor Google recommends and the default in most modern themes.
Reviews
There are no reviews for this plugin.
Contributors & Developers
“Peakspire Font Loading Optimizer” is open source software. The following people have contributed to this plugin.
ContributorsTranslate “Peakspire Font Loading Optimizer” into your language.
Interested in development?
Browse the code, check out the SVN repository, or subscribe to the development log by RSS.
Changelog
1.0.3
- Discovery prioritization: same-host stylesheets scanned first; CDN-hosted stylesheets no longer consume scan slots (they cannot yield same-host WOFF2 URLs)
- Real-theme tested on Twenty Twenty-Four: external CSS fonts correctly preloaded, inline declarations correctly skipped
- PHP 7.4 literal execution verified (Docker php:7.4-cli, lint + token scan)
1.0.2
- Security hardening: SSRF defense (private/loopback/link-local IP deny-list before fetch), cache-hit re-validation (same-host + is_string on every cached entry), corrupt-lock-value recovery (stale-reclaimable, not live-forever)
- Availability: preg_replace NULL guard on backtrack-limit exhaustion (never blanks a page)
- CSS correctness: @font-face rewrite scoped to
- Measured: zero LCP regression on inline-font themes; preload timing verified on external-CSS pages
1.0.0
- Initial release: WOFF2 preload discovery, global font-display:swap injection, optional Google Fonts removal, optional dashicons removal for guests.
