Skip to content

Commit

Permalink
js: prevent multiloading of comments block
Browse files Browse the repository at this point in the history
  • Loading branch information
gorenburg committed Feb 3, 2025
1 parent fd8a4e8 commit 9b464fb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/components/comments.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script lang="ts">
import { onDestroy, onMount } from "svelte"
let isCommentsBlockLoaded = false
let commentsEl: HTMLElement
let observer: IntersectionObserver
Expand All @@ -9,6 +10,7 @@
}
onMount(() => {
if (isCommentsBlockLoaded) { return }
observer = new IntersectionObserver(loadCommentsLibrary, options)
observer.observe(commentsEl)
})
Expand All @@ -26,6 +28,7 @@
scriptEl.setAttribute('data-chirpy-domain', 'ilya.gorenburg.com')
document.body.appendChild(scriptEl)
isCommentsBlockLoaded = true
}
</script>

Expand Down

0 comments on commit 9b464fb

Please sign in to comment.