File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,13 @@ const mappings = new Map([
1010 [ '/docs/accessibility-warnings' , '/docs/svelte/compiler-warnings' ]
1111] ) ;
1212
13+ // selectively preload fonts
14+ const fonts = [
15+ 'dm-serif-display-latin-400-normal' ,
16+ 'eb-garamond-latin-400-normal' ,
17+ 'fira-sans-latin-400-normal'
18+ ] ;
19+
1320/** @type {import('@sveltejs/kit').Handle } */
1421export async function handle ( { event, resolve } ) {
1522 // Best effort to redirect from Svelte 4 docs to new docs
@@ -23,12 +30,11 @@ export async function handle({ event, resolve }) {
2330 const response = await resolve ( event , {
2431 preload : ( { type, path } ) => {
2532 if ( type === 'font' ) {
26- // only preload header font, everything else is lower priority,
27- // otherwise it causes congestion that messes up LCP
28- return path . includes ( 'dm-serif-display-latin-400-normal' ) && path . endsWith ( '.woff2' ) ;
33+ if ( ! path . endsWith ( '.woff2' ) ) return false ;
34+ return fonts . some ( ( font ) => path . includes ( font ) ) ;
2935 }
3036
31- return true ;
37+ return type === 'js' || type === 'css' ; // future-proof, if we add `assets` later
3238 }
3339 } ) ;
3440
You can’t perform that action at this time.
0 commit comments