Skip to content

Commit d7aac28

Browse files
authored
Use preconnects to speed up font loading (#337)
* Use preconnects to speed up font loading See https://sia.codes/posts/making-google-fonts-faster/ * Avoid linkchecking preconnects
1 parent b0bc0c5 commit d7aac28

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

doc/netlify.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,6 @@
2929

3030
[[plugins]]
3131
package = "netlify-plugin-checklinks"
32+
33+
[plugins.inputs]
34+
skipPatterns = ['https://fonts.gstatic.com', 'https://fonts.googleapis.com']

layouts/partials/css.html

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,25 @@
22
{{- $page := . -}}
33

44
{{- $inServerMode := .Site.IsServer -}}
5-
{{- $serverOpts := cond ($inServerMode) (dict "enableSourceMap" true) (dict "outputStyle" "compressed") -}}
5+
{{- $serverOpts := cond ($inServerMode) (dict "enableSourceMap" true) (dict "outputStyle" "compressed") -}}
66
{{- $sassCompiler := dict "transpiler" "dartsass" -}}
7-
{{- $cssOpts := collections.Merge $sassCompiler $serverOpts -}}
8-
{{- $sass := (slice "theme-css/pst/pydata-sphinx-theme.scss") -}}
7+
{{- $cssOpts := collections.Merge $sassCompiler $serverOpts -}}
8+
{{- $sass := (slice "theme-css/pst/pydata-sphinx-theme.scss") -}}
99

1010
<!-- Fonts -->
11-
{{- $fontName := .Site.Params.font.name | default "Open Sans" -}}
12-
{{- $fontFace := replace $fontName " " "+" -}}
13-
{{- $fontSizes := delimit (.Site.Params.font.sizes | default (slice 300 400 600 700)) "," -}}
14-
{{- $fontUrl := printf "https://fonts.googleapis.com/css?family=%s:%s" $fontFace $fontSizes -}}
11+
{{- $fontName := .Site.Params.font.name | default "Open Sans" -}}
12+
{{- $fontFace := replace $fontName " " "+" -}}
13+
{{- $fontSizes := delimit (.Site.Params.font.sizes | default (slice 300 400 600 700)) ";" -}}
14+
{{- $fontUrl := printf "https://fonts.googleapis.com/css2?family=%s:wght@%s" $fontFace $fontSizes -}}
1515

1616
<link rel="icon" href="{{ "images/favicon.ico" | relURL }}" />
17+
18+
<link rel="preconnect" href="https://fonts.googleapis.com">
19+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
1720
<link rel="stylesheet" href="{{ $fontUrl }}">
1821

19-
<!-- Fallback font for symbols (such as "🛈"). -->
20-
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Noto+Sans+Symbols+2">
22+
<!-- Fallback font for symbols (such as "🛈"). --
23+
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Noto+Sans+Symbols+2">
2124
2225
<!-- SASS -->
2326
{{- range $sass -}}

0 commit comments

Comments
 (0)