fix: lazy loading
This commit is contained in:
parent
871c6d6959
commit
a8cf13157b
@ -1,16 +1,16 @@
|
||||
window.onload = function () {
|
||||
// Get all <img> elements with loading="lazy"
|
||||
var lazyImages = document.querySelectorAll('img[loading="lazy"]');
|
||||
window.onload = function () {
|
||||
// Get all <img> elements with loading="lazy"
|
||||
var lazyImages = document.querySelectorAll('img[loading="lazy"]');
|
||||
|
||||
console.log(lazyImages)
|
||||
console.log(lazyImages)
|
||||
|
||||
// Loop through each image and apply the fade-in effect
|
||||
lazyImages.forEach(function (lazyImage) {
|
||||
console.log(lazyImage)
|
||||
var img = new Image();
|
||||
img.src = lazyImage.src;
|
||||
img.onload = function () {
|
||||
lazyImage.style.opacity = 1;
|
||||
};
|
||||
});
|
||||
};
|
||||
// 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;
|
||||
};
|
||||
});
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user