Skip to content

Commit 62d6d55

Browse files
fix: preload Inter font and use font-display: optional to prevent text reflow CLS
Preload the latin Inter woff2 so the font is available before first paint. Switch font-display from swap to optional so the browser never swaps in a late-arriving font, eliminating text reflow shifts.
1 parent e71479b commit 62d6d55

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/routes/__root.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ export const Route = createRootRouteWithContext<{
7575
}),
7676
],
7777
links: [
78+
{
79+
rel: 'preload',
80+
href: '/fonts/Inter-latin.woff2',
81+
as: 'font',
82+
type: 'font/woff2',
83+
crossOrigin: 'anonymous',
84+
},
7885
{ rel: 'stylesheet', href: appCss },
7986
{
8087
rel: 'apple-touch-icon',

src/styles/app.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ mark {
794794
}
795795

796796
@font-face {
797-
font-display: swap;
797+
font-display: optional;
798798
font-family: 'Inter';
799799
font-style: normal;
800800
font-weight: 100 900;
@@ -806,7 +806,7 @@ mark {
806806
}
807807

808808
@font-face {
809-
font-display: swap;
809+
font-display: optional;
810810
font-family: 'Inter';
811811
font-style: normal;
812812
font-weight: 100 900;

0 commit comments

Comments
 (0)