Skip to content

Commit b5c34a6

Browse files
committed
feat: Preload critical fonts
This change preloads critical fonts to improve page load performance by breaking the request chain.
1 parent 2458c99 commit b5c34a6

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

data/fonts.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# data/fonts.toml
2+
# List of critical fonts to preload. Paths are relative to the /assets directory.
3+
files = [
4+
"fonts/inter-v19-latin-regular.woff2",
5+
"fonts/inter-v19-latin-600.woff2",
6+
"fonts/inter-v19-latin-700.woff2",
7+
"fonts/roboto-slab-v35-latin-700.woff2"
8+
]

layouts/partials/essentials/head.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@
6464
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
6565
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
6666
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
67+
{{/* Preload critical fonts to break the request chain */}}
68+
{{ range site.Data.fonts.files }}
69+
{{ with resources.Get . }}
70+
<link rel="preload" href="{{ .RelPermalink }}" as="font" type="font/woff2" crossorigin>
71+
{{ end }}
72+
{{ end }}
6773

6874
<!-- opengraph and twitter card -->
6975
{{ partial "components/base-seo.html" . }}

0 commit comments

Comments
 (0)