aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Kagamino Lehoux <martin@lehoux.net>2025-10-06 21:44:41 +0200
committerMartin Kagamino Lehoux <martin@lehoux.net>2025-10-06 21:44:41 +0200
commit8cd02c52e7abcbddd97afcf697c10d76d358ba44 (patch)
treee6b6ebe68191fb522d2de030c3ebaa227007f3ae
parent9a29017390e5b9ceaf0e247652e5d5b657268909 (diff)
Defer mathjax script
-rw-r--r--layouts/partials/head/styles.html18
1 files changed, 11 insertions, 7 deletions
diff --git a/layouts/partials/head/styles.html b/layouts/partials/head/styles.html
index cfab45a..e5432ad 100644
--- a/layouts/partials/head/styles.html
+++ b/layouts/partials/head/styles.html
@@ -1,17 +1,21 @@
-{{/* Resources */}}
+{{/* Resources */}}
{{- $tailwind := resources.Get "css/tailwind.css" | postCSS (dict "config" "./config/postcss.config.js") -}}
{{/* MathJax */}}
-<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
-<script type="text/x-mathjax-config">MathJax.Hub.Config({ tex2jax: { inlineMath: [['$','$'], ['\\(','\\)']] } });</script>
+<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML" defer></script>
+<script type="text/x-mathjax-config">
+document.addEventListener('DOMContentLoaded', function () {
+ MathJax.Hub.Config({ tex2jax: { inlineMath: [['$','$'], ['\\(','\\)']] } });
+});
+</script>
-{{/* Processor */}}
-{{- $styles := slice $tailwind | resources.Concat "css/app.css" -}}
+{{/* Processor */}}
+{{- $styles := slice $tailwind | resources.Concat "css/app.css" -}}
-{{/* Output */}}
+{{/* Output */}}
{{- if eq hugo.Environment "development" -}}
<link rel="stylesheet" href="{{ $styles.Permalink | absURL }}" />
-{{- else -}}
+{{- else -}}
{{- $styles := $styles | minify | fingerprint | resources.PostProcess -}}
<link rel="stylesheet" href="{{ $styles.Permalink }}" integrity="{{ $styles.Data.Integrity }}" />
{{- end -}}