lazy img
This commit is contained in:
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');
|
||||
};
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user