silvester-23/static/lazy.js
2023-11-20 16:43:36 +01:00

17 lines
405 B
JavaScript

window.onload = function(){
var lazyImages = [...document.querySelectorAll("img[loading='lazy']")];
for (let i = 0; i < lazyImages.length; i++) {
var element = lazyImages[i];
element.classList.add("lazy-image")
element.onload = function(){
element.classList.add("loaded");
}
element.addEventListener("load", function(){
element.classList.add("loaded");
})
}
}