mirror of
https://github.com/gohugoio/hugo.git
synced 2026-08-29 17:52:38 +00:00
theme: Move initColorScheme() to head
This should reduce the amount of blocking JS. Also remove the initColorScheme() in `turbo:render` which is not needed after we moved the `dark` class from body to documentElement.
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
import { initColorScheme } from './alpinejs/stores/index';
|
||||
|
||||
(function () {
|
||||
// This allows us to initialize the color scheme before AlpineJS etc. is loaded.
|
||||
initColorScheme();
|
||||
})();
|
||||
@@ -1,6 +1,10 @@
|
||||
import { scrollToActive } from 'js/helpers/index';
|
||||
import { initColorScheme } from './alpinejs/stores/index';
|
||||
|
||||
(function () {
|
||||
// This allows us to initialize the color scheme before AlpineJS etc. is loaded.
|
||||
initColorScheme();
|
||||
|
||||
// Now we know that the browser has JS enabled.
|
||||
document.documentElement.classList.remove('no-js');
|
||||
|
||||
|
||||
@@ -8,14 +8,6 @@ import focus from '@alpinejs/focus';
|
||||
|
||||
var debug = 0 ? console.log.bind(console, '[index]') : function () {};
|
||||
|
||||
// Turbolinks init.
|
||||
(function () {
|
||||
document.addEventListener('turbo:render', function (e) {
|
||||
// This is also called right after the body start. This is added to prevent flicker on navigation.
|
||||
initColorScheme();
|
||||
});
|
||||
})();
|
||||
|
||||
// Set up and start Alpine.
|
||||
(function () {
|
||||
// Register AlpineJS plugins.
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
{{ with resources.Get "js/body-start.js" | js.Build (dict "minify" true) }}
|
||||
{{ partial "helpers/linkjs.html" (dict "r" . "attributes" (dict "" "")) }}
|
||||
{{ end }}
|
||||
|
||||
Reference in New Issue
Block a user