Compare commits
3 Commits
564a1f96e0
...
8ec196af15
| Author | SHA1 | Date | |
|---|---|---|---|
| 8ec196af15 | |||
| 69c47e3cf0 | |||
|
|
dd82088551 |
8
lazy-img.css
Normal file
8
lazy-img.css
Normal file
@ -0,0 +1,8 @@
|
||||
img[loading='lazy'] {
|
||||
opacity: 0;
|
||||
transition: opacity 0.5s ease !important;
|
||||
}
|
||||
|
||||
img.loaded {
|
||||
opacity: 1;
|
||||
}
|
||||
14
lazy-img.js
Normal file
14
lazy-img.js
Normal file
@ -0,0 +1,14 @@
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
/*var cssLink = document.createElement("link");
|
||||
cssLink.rel = "stylesheet";
|
||||
cssLink.href = "/cssjs/lazy-img.css";
|
||||
document.head.appendChild(cssLink);*/
|
||||
|
||||
var images = document.querySelectorAll('img[loading="lazy"]');
|
||||
|
||||
images.forEach(function(image) {
|
||||
image.onload = function() {
|
||||
image.classList.add('loaded');
|
||||
};
|
||||
});
|
||||
});
|
||||
1
lazy-img.min.js
vendored
Normal file
1
lazy-img.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
document.addEventListener("DOMContentLoaded",function(){document.querySelectorAll('img[loading="lazy"]').forEach(function(n){n.onload=function(){n.classList.add("loaded")}})});
|
||||
Loading…
Reference in New Issue
Block a user