summaryrefslogtreecommitdiff
path: root/layouts/partials/scripts.html
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2024-12-19 15:13:48 +0800
committerEltrac <hi@guhub.cn>2024-12-19 15:13:48 +0800
commitdf4366e8b041198ba922a5dad34e41672283fad9 (patch)
tree72dd1fdc8eeec6ecc9e779b4d5509c37d4b7eda5 /layouts/partials/scripts.html
parent841597652a85c6f2e2a95c100c621214a0bc025e (diff)
feat: image lazyload & refactor: external js import
Diffstat (limited to 'layouts/partials/scripts.html')
-rw-r--r--layouts/partials/scripts.html13
1 files changed, 11 insertions, 2 deletions
diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html
index 75a1ec36..d8daaaa0 100644
--- a/layouts/partials/scripts.html
+++ b/layouts/partials/scripts.html
@@ -1,5 +1,7 @@
<!-- third-party libraries -->
-<script src="https://unpkg.com/swup@4"></script>
+{{ range .Site.Params.externalJSFiles -}}
+<script src="{{ $.Site.Params.staticPrefix }}{{ . | relURL }}"></script>
+{{- end }}
<script type="module">
import { init } from 'https://unpkg.com/@waline/client@v3/dist/waline.js';
@@ -24,7 +26,14 @@ function loadWalineComment() {
loadWalineComment();
+/* === lazyload === */
+var lazyLoadInstance = new LazyLoad();
+lazyLoadInstance.update();
+
/* === swup === */
const swup = new Swup();
-swup.hooks.on('page:view', loadWalineComment);
+swup.hooks.on('page:view', () => {
+ loadWalineComment();
+ lazyLoadInstance.update();
+});
</script>