diff --git a/_config.yml b/_config.yml
index 349c4cd0..db1d99ff 100755
--- a/_config.yml
+++ b/_config.yml
@@ -207,6 +207,7 @@ search:
comments:
service: # beaudar, utterances, giscus, twikoo, waline, artalk
comment_title: 快来参与讨论吧~
+ lazyload: false # true / false
# beaudar
# https://beaudar.lipk.org/
beaudar:
diff --git a/layout/_partial/comments/artalk/script.ejs b/layout/_partial/comments/artalk/script.ejs
index 14d33c31..74e70fc3 100644
--- a/layout/_partial/comments/artalk/script.ejs
+++ b/layout/_partial/comments/artalk/script.ejs
@@ -1,14 +1,16 @@
-
\ No newline at end of file
diff --git a/layout/_partial/comments/beaudar/script.ejs b/layout/_partial/comments/beaudar/script.ejs
index 53a7ceb4..2ca7f037 100644
--- a/layout/_partial/comments/beaudar/script.ejs
+++ b/layout/_partial/comments/beaudar/script.ejs
@@ -1,26 +1,23 @@
-
diff --git a/layout/_partial/comments/giscus/script.ejs b/layout/_partial/comments/giscus/script.ejs
index b07342bc..0788c184 100644
--- a/layout/_partial/comments/giscus/script.ejs
+++ b/layout/_partial/comments/giscus/script.ejs
@@ -1,22 +1,22 @@
-
diff --git a/layout/_partial/comments/twikoo/script.ejs b/layout/_partial/comments/twikoo/script.ejs
index a905f410..ed52fb06 100644
--- a/layout/_partial/comments/twikoo/script.ejs
+++ b/layout/_partial/comments/twikoo/script.ejs
@@ -1,20 +1,18 @@
-
\ No newline at end of file
diff --git a/layout/_partial/comments/utterances/script.ejs b/layout/_partial/comments/utterances/script.ejs
index a6febf3c..4def2d7d 100644
--- a/layout/_partial/comments/utterances/script.ejs
+++ b/layout/_partial/comments/utterances/script.ejs
@@ -1,26 +1,23 @@
-
diff --git a/layout/_partial/comments/waline/script.ejs b/layout/_partial/comments/waline/script.ejs
index 5da6ead3..ce2be28a 100644
--- a/layout/_partial/comments/waline/script.ejs
+++ b/layout/_partial/comments/waline/script.ejs
@@ -1,14 +1,16 @@
diff --git a/source/js/main.js b/source/js/main.js
index 6c4ecaf7..4894426a 100644
--- a/source/js/main.js
+++ b/source/js/main.js
@@ -58,6 +58,20 @@ const util = {
scrollComment: () => {
document.getElementById('comments').scrollIntoView({behavior: "smooth"});
},
+
+ viewportLazyload: (target, func, enabled = true) => {
+ if (!enabled || !("IntersectionObserver" in window)) {
+ func();
+ return;
+ }
+ const observer = new IntersectionObserver((entries) => {
+ if (entries[0].intersectionRatio > 0) {
+ func();
+ observer.disconnect();
+ }
+ });
+ observer.observe(target);
+ }
}
const hud = {