2023-11-20 17:13:17 +01:00
|
|
|
window.onload = function () {
|
|
|
|
// Get all <img> elements with loading="lazy"
|
|
|
|
var lazyImages = document.querySelectorAll('img[loading="lazy"]');
|
2023-11-20 16:16:23 +01:00
|
|
|
|
2023-11-20 17:13:17 +01:00
|
|
|
console.log(lazyImages)
|
2023-11-20 16:16:23 +01:00
|
|
|
|
2023-11-20 17:13:17 +01:00
|
|
|
// Loop through each image and apply the fade-in effect
|
|
|
|
lazyImages.forEach(function (lazyImage) {
|
|
|
|
lazyImage.classList.add('lazy-image');
|
|
|
|
var img = new Image();
|
|
|
|
img.src = lazyImage.src;
|
|
|
|
img.onload = function () {
|
|
|
|
lazyImage.style.opacity = 1;
|
|
|
|
};
|
|
|
|
});
|
|
|
|
};
|