summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-04-02 14:33:40 +0800
committerEltrac <hi@guhub.cn>2025-04-02 14:33:40 +0800
commit8bcbdf938f1f53afdd2f18ea1dce6c7efcf8ce97 (patch)
tree8d1bf17548a5ee15cd80cb13300a07ffa7ccff2a
parenta6ab204fd13c1dcedb44175b83a71bd701b01ee0 (diff)
perf: load fancybox only in single pages
Former-commit-id: 0b221b7f8f0ecb006fc9f17e01e7689a3cc3a816
-rw-r--r--hugo.yaml1
-rw-r--r--layouts/partials/scripts.html9
2 files changed, 6 insertions, 4 deletions
diff --git a/hugo.yaml b/hugo.yaml
index edf6fa84..b459c002 100644
--- a/hugo.yaml
+++ b/hugo.yaml
@@ -85,7 +85,6 @@ params:
extraCSSFiles:
- /pagefind/pagefind-ui.css
externalJSFIles:
- - /js/fancybox.umd.js
- /js/littlefoot.js
- /pagefind/pagefind-ui.js
footerLinks:
diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html
index b22c8989..dbf6aee0 100644
--- a/layouts/partials/scripts.html
+++ b/layouts/partials/scripts.html
@@ -8,9 +8,12 @@
<script>{{ $lazyload.Content | safeJS }}</script>
{{- end }}
-{{- $fancybox := resources.Get "js/fancybox.js" | minify }}
-{{- if $fancybox }}
- <script>{{ $fancybox.Content | safeJS }}</script>
+{{- if or (in .Section "posts") (in .Section "cards") (in .Section "library") (eq .Type "single") }}
+ <script src="/js/fancybox.umd.js"></script>
+ {{- $fancybox := resources.Get "js/fancybox.js" | minify }}
+ {{- if $fancybox }}
+ <script>{{ $fancybox.Content | safeJS }}</script>
+ {{- end }}
{{- end }}
<script>