Get started with lazysizes CDN
MIT licensed
LazySizes: library for lazy-loading images, enhancing page speed by loading media near viewport entry.
Tags:- lazy
- loader
- lazyloader
- lazyload
- performance
- responsive
- image
- responsive images
- picture
- srcset
- respimg
- respimage
- include
Stable version
Copied!
How to start using lazysizes CDN
<!DOCTYPE html>
<html>
<head>
<title>Get started with lazysizes CDN - cdnhub.io</title>
<link rel="stylesheet" href="styles.css">
<script src="https://cdn.cdnhub.io/lazysizes/5.3.2/lazysizes.min.js" async></script>
</head>
<body>
<img data-src="image1.jpg" class="lazyload" alt="Image 1">
<img data-src="image2.jpg" class="lazyload" alt="Image 2">
<img data-src="image3.jpg" class="lazyload" alt="Image 3">
<script>
document.addEventListener("DOMContentLoaded", function() {
if ("IntersectionObserver" in window) {
let lazyImages = document.querySelectorAll(".lazyload");
let lazyImageObserver = new IntersectionObserver(function(entries, observer) {
entries.forEach(function(entry) {
if (entry.isIntersecting) {
let lazyImage = entry.target;
lazyImage.src = lazyImage.dataset.src;
lazyImage.classList.remove("lazyload");
lazyImageObserver.unobserve(lazyImage);
}
});
});
lazyImages.forEach(function(lazyImage) {
lazyImageObserver.observe(lazyImage);
});
}
});
</script>
</body>
</html>
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
All versions
0.4.0
0.5.0
0.5.1
0.5.2
0.5.3
0.6.0
0.6.1
0.7.1
0.7.2
0.8.0
0.8.1
0.9.0
1.0.0
1.0.0-alpha
1.0.0-rc1
1.0.0-RC3
1.0.1
1.0.1-RC1
1.1.0
1.1.0-rc1
1.1.0-rc2
1.1.0-rc3
1.1.2
1.1.3
1.1.3-RC1
1.1.4
1.1.4-rc1
1.1.5
1.1.5-rc1
1.2.0
1.2.0-rc1
1.2.0-rc2
1.2.1
1.2.2
1.2.3-rc1
1.2.3-rc2
1.3.0
1.3.1
1.3.2
1.4.0
1.4.0-rc1
1.5.0
1.5.0-rc1
1.5.0-rc3
1.5.0-rc4
2.0.0
2.0.0-rc1
2.0.0-rc2
2.0.1
2.0.2
2.0.2-rc1
2.0.3
2.0.4
2.0.5
2.0.6
2.0.6-rc1
2.0.6-rc2
2.0.7
3.0.0
3.0.0-rc1
3.0.0-rc2
3.0.0-rc3
3.0.0-rc4
4.0.0
4.0.0-rc1
4.0.0-rc2
4.0.0-rc3
4.0.0-rc4
4.0.1
4.0.1-beta1
4.0.2
4.0.3
4.0.4
4.1.0
4.1.1
4.1.2
4.1.3
4.1.4
4.1.5
4.1.8
5.0.0
5.0.0-beta1
5.0.0-beta2
5.0.0-rc1
5.0.0-rc2
5.1.0
5.1.1
5.1.2
5.2.0
5.2.1
5.2.1-rc1
5.2.1-rc2
5.2.2
5.3.0
5.3.0-beta1
5.3.1
*** 5.3.2