Don't load comments until details element is expanded
This commit is contained in:
parent
897015f3f2
commit
6b276fdbe0
|
@ -1,4 +1,12 @@
|
||||||
fetchComments();
|
let commentsLoaded = false;
|
||||||
|
const details = document.getElementById("comments-container");
|
||||||
|
details.addEventListener("toggle", (even) => {
|
||||||
|
if (details.open && !commentsLoaded) {
|
||||||
|
fetchComments().then(() => {
|
||||||
|
commentsLoaded = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
async function fetchComments() {
|
async function fetchComments() {
|
||||||
const res = await fetch(`/comments?id=${permalink}`);
|
const res = await fetch(`/comments?id=${permalink}`);
|
||||||
|
|
Loading…
Reference in New Issue