Defer some heavier CSS until later to help page loading times.

Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
This commit is contained in:
Danila Fedorin 2023-12-30 16:00:57 -08:00
parent 1f64536c30
commit 973be263dc
2 changed files with 7 additions and 5 deletions

View File

@ -0,0 +1,2 @@
<link rel="preload" href="{{ .url }}" as="style" onload="this.onload=null;this.rel='stylesheet'" {{ .extra | safeHTMLAttr }}>
<noscript><link rel="stylesheet" href="{{ .url }}"></noscript>

View File

@ -14,8 +14,8 @@
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inconsolata:wght@400;700&family=Raleway&family=Lora&display=block" media="screen">
<!-- External CSS (normalize and KaTeX -->
<link rel="stylesheet" href="{{ .Site.Params.normalizeCssUrl }}" media="screen">
<link rel="stylesheet" href="{{ .Site.Params.katexCssUrl }}" crossorigin="anonymous">
{{ partial "defercss.html" (dict "url" .Site.Params.normalizeCssUrl "extra" "") }}
{{ partial "defercss.html" (dict "url" .Site.Params.katexCssUrl "extra" "crossorigin=\"anonymous\"") }}
<!-- Links to other formats (RSS, TOML) -->
{{ range .AlternativeOutputFormats -}}
@ -29,9 +29,9 @@
{{ $icon := resources.Get "img/favicon.png" }}
<style>.sidenote-checkbox { display: none; }</style>
<style>.feather { width: 1rem; height: 1rem; }</style>
<link rel="stylesheet" href="{{ $style.Permalink }}" media="screen">
<link rel="stylesheet" href="{{ $sidenotes.Permalink }}" media="screen">
<link rel="stylesheet" href="{{ $code.Permalink }}" media="screen">
<link rel="stylesheet" href="{{ $style.Permalink }}">
{{ partial "defercss.html" (dict "url" $sidenotes.Permalink "extra" "") }}
{{ partial "defercss.html" (dict "url" $code.Permalink "extra" "") }}
<link rel="icon" type="image/png" href="{{ $icon.Permalink }}">
{{ if .Site.IsServer }}