silvester-23/static/lazy.js

17 lines
405 B
JavaScript
Raw Normal View History

2023-11-20 16:16:23 +01:00
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")
2023-11-20 16:43:36 +01:00
element.onload = function(){
element.classList.add("loaded");
}
2023-11-20 16:16:23 +01:00
element.addEventListener("load", function(){
element.classList.add("loaded");
})
}
}