perf: pre-connect to Google Fonts if using Google Fonts

Increase performance.
This commit is contained in:
George Cushen 2020-08-31 17:36:30 +01:00
commit 07facf5828
2 changed files with 7 additions and 1 deletions

View file

@ -21,7 +21,7 @@
<p class="powered-by">
{{ if not site.Params.i_am_a_sponsor }}
Published with
<a href="https://sourcethemes.com/academic/" target="_blank" rel="noopener">Academic Website Builder</a>
<a href="https://wowchemy.com" target="_blank" rel="noopener">Wowchemy Website Builder</a>
{{ end }}
{{ if not (in (slice "book" "docs" "updates") .Type) }}

View file

@ -44,6 +44,12 @@
<link rel="alternate" hreflang="{{ site.LanguageCode | default "en-us" }}" href="{{ .Permalink }}">
{{ partial "functions/parse_theme" . }}
{{/* Pre-connect to Google Fonts if the site's Font Theme uses them. */}}
{{ with ($scr.Get "google_fonts") }}
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
{{end}}
{{ $css := site.Data.assets.css }}
{{ $js := site.Data.assets.js }}
{{ if ne ($scr.Get "primary") "#fff" }}