enhance: DOMContentLoaded instead of line
This commit is contained in:
parent
4d591adbb5
commit
2f7c70e846
@ -21,4 +21,8 @@ function darkmode_disable() {
|
||||
|
||||
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches && localStorage.getItem('dark-mode') === null) {
|
||||
localStorage.setItem('dark-mode', 'true');
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
document.getElementById("dark-mode-button").addEventListener("click", darkmode);
|
||||
});
|
@ -1,2 +0,0 @@
|
||||
/* initialize onclick here because the main point is to avoid inline scripts and stylesheets */
|
||||
document.getElementById("dark-mode-button").addEventListener("click", darkmode);
|
@ -63,15 +63,6 @@
|
||||
Simply place a custom_body.html into
|
||||
your local /layouts/partials-directory -->
|
||||
{{- partial "custom_body.html" . -}}
|
||||
|
||||
{{- /* Onclick Javascript */}}
|
||||
{{- $darkmode_onclick := (resources.Get "js/darkmode_click.js") | resources.Minify }}
|
||||
{{- if not site.Params.assets.disableFingerprinting }}
|
||||
{{- $darkmode_onclick := $darkmode_onclick | fingerprint }}
|
||||
<script crossorigin="anonymous" src="{{ $darkmode_onclick.RelPermalink }}" integrity="{{ $darkmode_onclick.Data.Integrity }}"></script>
|
||||
{{ else }}
|
||||
<script crossorigin="anonymous" src="{{ $darkmode_onclick.RelPermalink }}"></script>
|
||||
{{ end }}
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user