Move persistent theme script earlier

This makes it faster for the perceived performance and placing it the
moment after loading the stylesheet is the quickest way to avoid
unstyled flash of content.
This commit is contained in:
Gabriel Arazas 2023-03-06 23:24:08 +08:00
parent b8ff9e866f
commit db5a0b48de

View File

@ -18,6 +18,14 @@
{{- $style = $style | resources.Minify | resources.Fingerprint -}}
{{- end }}
<link rel="stylesheet" href="{{ $style.Permalink }}" />
{{- /* Persistent theme.
It's a very small script so there's little effect on perceived performance. */ -}}
<script>
let theme = window.localStorage.getItem('theme');
if (theme) {
document.documentElement.dataset.theme = theme;
}
</script>
<link rel="shortcut icon" href="{{ absURL "favicon.png" }}" />
@ -50,13 +58,3 @@
{{ template "_internal/disqus.html" . }}
{{- end }}
{{- /* Persistent theme.
It's a very small script so there's little effect on perceived performance. */ -}}
<script>
let theme = window.localStorage.getItem('theme');
if (theme) {
document.documentElement.dataset.theme = theme;
}
</script>