forked from
quillmatiq.com/augment
Fork of Chiri for Astro for my blog
1<script is:inline>
2 // Global handler: Automatically remove the img-placeholder class after images are loaded
3 function removeImgPlaceholder() {
4 document.querySelectorAll('img.img-placeholder').forEach(function (img) {
5 if (img.complete) {
6 img.classList.remove('img-placeholder')
7 } else {
8 // Skip if already bound
9 if (img.dataset.placeholderBound) return
10 img.dataset.placeholderBound = 'true'
11
12 img.addEventListener('load', function () {
13 img.classList.remove('img-placeholder')
14 })
15 }
16 })
17 }
18
19 // Use only astro:page-load as it fires on initial load and navigation
20 document.addEventListener('astro:page-load', removeImgPlaceholder)
21</script>