lazy-loading done
Some checks failed
ci / site (push) Has been cancelled
publish-image / publish (push) Has been cancelled

This commit is contained in:
2026-02-10 15:59:03 -05:00
parent 7bd51837de
commit ac3de3e142
24 changed files with 923 additions and 16 deletions

View File

@@ -204,5 +204,30 @@ const canonicalUrl = `${siteUrl}${canonicalPath.startsWith("/") ? canonicalPath
mql.addEventListener("change", () => setOpen(!mql.matches));
})();
</script>
<script is:inline>
(() => {
function reveal(img) {
img.classList.remove("img-loading");
img.classList.add("img-loaded");
var wrap = img.closest(".img-shimmer-wrap");
if (wrap) wrap.classList.add("img-loaded");
}
var imgs = document.querySelectorAll("img.img-loading");
for (var i = 0; i < imgs.length; i++) {
(function(img) {
if (img.complete && img.naturalWidth > 0) {
reveal(img);
return;
}
img.addEventListener("load", function() { reveal(img); });
img.addEventListener("error", function() {
var wrap = img.closest(".img-shimmer-wrap");
if (wrap) wrap.classList.add("img-error");
});
})(imgs[i]);
}
})();
</script>
</body>
</html>