Pulse · web performance
font-pulse
Audit how your built site loads web fonts: font-display, preloads, WOFF2, subsetting, unused weights and total font payload.
npm i -D @mrlouiswright/font-pulsePublished to GitHub Packages: add @mrlouiswright:registry=https://npm.pkg.github.com to .npmrc first (installing needs a token with read:packages).
What it checks
- Loading
font-displaymissing orblock/auto; Google Fonts URLs withoutdisplay=swap; third-party font hosts withoutpreconnect. - Preloadsself-hosted fonts with no preload, preloads without
crossorigin(double download), preloads of files no@font-faceuses, and too many font preloads. - Formats and size
@font-facewithout a WOFF2 source, font files over 100 kB (subset them), large fonts withoutunicode-range. - Wastefamilies declared but never used in
font-family, weights and italic faces never used (headings and<strong>count as bold), more than six font files per page, and a per-page payload budget (default 300 kB). - Understands real CSSthe
fontshorthand, CSS custom properties, variable-font weight ranges,@importchains and inline styles.
Quick usage
CLI
npx font-pulse dist
npx font-pulse public --max-payload-kb 200 --fail-on medium
npx font-pulse _site --format markdown >> $GITHUB_STEP_SUMMARY
API
import { check, parseCss } from "font-pulse";
parseCss("@font-face{font-family:Inter;src:url(i.woff2) format('woff2')}").faces;
const report = check("dist", { maxPayload: 200 * 1024 });
Every option is documented in the font-pulse docs.
CI / GitHub Action
permissions:
contents: read
security-events: write # only needed for the SARIF upload
jobs:
font-pulse:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with: { persist-credentials: false }
- run: npm ci && npm run build # produce the static site first
- uses: MrLouisWright/font-pulse@v1
with:
path: dist
fail-on: high
sarif: font-pulse.sarif
- uses: github/codeql-action/upload-sarif@v3
if: always()
with: { sarif_file: font-pulse.sarif }