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"> <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 --> <!-- External CSS (normalize and KaTeX -->
<link rel="stylesheet" href="{{ .Site.Params.normalizeCssUrl }}" media="screen"> {{ partial "defercss.html" (dict "url" .Site.Params.normalizeCssUrl "extra" "") }}
<link rel="stylesheet" href="{{ .Site.Params.katexCssUrl }}" crossorigin="anonymous"> {{ partial "defercss.html" (dict "url" .Site.Params.katexCssUrl "extra" "crossorigin=\"anonymous\"") }}
<!-- Links to other formats (RSS, TOML) --> <!-- Links to other formats (RSS, TOML) -->
{{ range .AlternativeOutputFormats -}} {{ range .AlternativeOutputFormats -}}
@ -29,9 +29,9 @@
{{ $icon := resources.Get "img/favicon.png" }} {{ $icon := resources.Get "img/favicon.png" }}
<style>.sidenote-checkbox { display: none; }</style> <style>.sidenote-checkbox { display: none; }</style>
<style>.feather { width: 1rem; height: 1rem; }</style> <style>.feather { width: 1rem; height: 1rem; }</style>
<link rel="stylesheet" href="{{ $style.Permalink }}" media="screen"> <link rel="stylesheet" href="{{ $style.Permalink }}">
<link rel="stylesheet" href="{{ $sidenotes.Permalink }}" media="screen"> {{ partial "defercss.html" (dict "url" $sidenotes.Permalink "extra" "") }}
<link rel="stylesheet" href="{{ $code.Permalink }}" media="screen"> {{ partial "defercss.html" (dict "url" $code.Permalink "extra" "") }}
<link rel="icon" type="image/png" href="{{ $icon.Permalink }}"> <link rel="icon" type="image/png" href="{{ $icon.Permalink }}">
{{ if .Site.IsServer }} {{ if .Site.IsServer }}