perf: replace Font Awesome with inline SVG icons - #271
Conversation
Font Awesome 4 is EOL and was pulled from jsdelivr as a render-blocking stylesheet, then downloaded a whole icon webfont, to draw 3 glyphs of site chrome. With animate.css already bundled in #270, removing it takes the last third-party stylesheet off the critical path. - new src/components/UiIcons.tsx: IconBars, IconArrowLeft, IconExternalLink as inline SVG, sized in em so they scale with the inherited font-size and inherit text colour. All decorative, so aria-hidden - every call site has adjacent text or its own aria-label. - .ui-icon in styles.scss nudges them onto the text baseline where the webfont glyphs sat. - the example code in src/examples/functions.ts uses emoji instead: those snippets are displayed verbatim as documentation, so inlining SVG there would wreck them. Existing aria labels are unchanged. - drop the font-awesome <link>, and with it the now-dead jsdelivr preconnect from #267. No stylesheet is loaded from a third party any more. The remaining external origins are all deferred, after-mount, or on-demand, so they keep dns-prefetch only. The stray fa-info-circle in validation-message-custom-icon-src.tsx is left alone: it runs inside Sandpack, which only ever injects sweetalert2 and never had Font Awesome, so it was already not rendering. Pre-existing and untouched by this change. Part of #259 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Correction: my justification for leaving I wrote that the stray That is false. The recipe passes its own hidden
Two things follow:
The site-side removal in this PR is unaffected: no font-awesome reference remains in the JS bundle or in any served page. |
#271 changed the customHtml example's buttons from fa-thumbs-up / fa-thumbs-down to emoji, but left codepenCssExternal pointing at font-awesome, so "Edit in CodePen" still injected a stylesheet nothing used. The other two codepenCssExternal values stay: animate.css is still needed by the customAnimation example's pen, and bootstrap4-buttons.css by the bootstrap example's. No font-awesome reference remains in the JS bundle. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Part of #259. With animate.css bundled in #270, this removes the last third-party stylesheet from the critical path.
Font Awesome 4 is EOL (last release 2016) and was fetched from jsdelivr as a render-blocking stylesheet, which then pulled a whole icon webfont, to draw 3 glyphs of site chrome.
Changes
src/components/UiIcons.tsx(new) —IconBars,IconArrowLeft,IconExternalLinkas inline SVG. Sized inemso they scale with the inheritedfont-size(.show-sidebarsets1.8em, and the icon follows), and they inherit text colour viacurrentColor.All three are decorative and
aria-hidden— every call site either has adjacent text ("Back to Recipe Gallery", "jsDelivr CDN") or its ownaria-label(the menu button). So nothing is lost for assistive tech..ui-iconinstyles.scssnudges them onto the text baseline where the webfont glyphs sat (vertical-align: -0.125em).Example code uses emoji instead. The three remaining icons live in
src/examples/functions.ts, whose source is stringified and displayed verbatim as the documentation (see the minify finding on this issue). Inlining SVG path data there would wreck those snippets, so:Existing
confirmButtonAriaLabel/cancelButtonAriaLabelvalues are unchanged, so the buttons keep their accessible names. This is the one visible content change in the PR — the thumbs-up/down and arrow in the "custom HTML" and T&C examples now render as emoji.Removed the
font-awesome<link>and, with it, the jsdelivrpreconnectadded in #267 — nothing loads from that origin any more, so the hint was dead weight.Verification
font-awesomeorjsdelivr.<link rel="stylesheet">left in the head is same-origin:/assets/components-*.css.analytics.limonte.dev(deferred),api.github.com/api.npmjs.org/ghbtns.com(after mount), and Algolia (on demand) — alldns-prefetchonly, none blocking..ui-iconis in the emitted CSS.fa fa-class remains in the JS bundle.bun run lintandbun run buildpass.Left alone deliberately
recipe-gallery/validation-message-custom-icon-src.tsx:12still usesfa-info-circle. That runs inside Sandpack, which only ever injectssweetalert2plus per-recipe deps and never had Font Awesome — so that icon was already not rendering in its own preview. Pre-existing, unaffected by this change, and fixing it means rewriting a recipe whose subject is custom icons. Worth its own issue.Worth a look after deploy
The mobile hamburger button, the "Back to Recipe Gallery" link, the two external-link icons, and the two affected examples on the homepage. This is verified by build output and CSS reasoning, not by rendering.
Still open in #259
Lazy-mounting Sandpack (1.17 MB / 317 KB gzipped on every recipe page).
🤖 Generated with Claude Code