<!-- Сделала Fedyaeva http://front-test.tilda.ws/links ♥ -->
<picture>
<source srcset="gif.png" type="image/apng">
<source srcset="gif.avifs" type="image/avif" />
<source srcset="gif.webp" type="image/webp" />
<img src="image.gif" width="450" height="330" alt="Cat boss" loading="lazy" decoding="async">
</picture>
<!-- Сделала Fedyaeva http://front-test.tilda.ws/links ♥ -->
<style>
.lazy {
width: 100%;
height: auto;
}
</style>
<img class="lazy" src="ссылка на заглушку" data-src="ссылка на gif" alt="I'm cat boss! Big boss!">
<!-- Сделала Fedyaeva http://front-test.tilda.ws/links ♥ -->
<script>
document.addEventListener("DOMContentLoaded", function() {
let lazyImages = [].slice.call(document.querySelectorAll("img.lazy"));
if ("IntersectionObserver" in window) {
let lazyImageObserver = new IntersectionObserver(function(entries, observer) {
entries.forEach(function(entry) {
if (entry.isIntersecting) {
let lazyImage = entry.target;
lazyImage.src = lazyImage.dataset.src;
// lazyImage.srcset = lazyImage.dataset.srcset;
lazyImage.classList.remove("lazy");
lazyImageObserver.unobserve(lazyImage);
}
});
});
lazyImages.forEach(function(lazyImage) {
lazyImageObserver.observe(lazyImage);
});
}
});
</script>
<!-- Сделала Fedyaeva http://front-test.tilda.ws/links ♥ -->
<style>
.block--visible.test-shape .tn-atom {
background-image: url('https://images.unsplash.com/photo-1675019335923-05c6ddce8546?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=774&q=80');
background-size: cover;
background-repeat: no-repeat;
}
</style>
<script>
document.addEventListener("DOMContentLoaded", function() {
let lazyImages = [].slice.call(document.querySelectorAll(".test-shape"));
if ("IntersectionObserver" in window) {
let lazyImageObserver = new IntersectionObserver(function(entries, observer) {
entries.forEach(function(entry) {
if (entry.isIntersecting) {
let lazyImage = entry.target;
lazyImage.classList.add('block--visible');
}
});
});
lazyImages.forEach(function(lazyImage) {
lazyImageObserver.observe(lazyImage);
});
}
});
</script>
<!-- Сделала Fedyaeva http://front-test.tilda.ws/links ♥ -->
<video class="lazy" autoplay muted loop playsinline poster="ссылка на заглушку" style="width: 100%; height: auto;">
<source data-src="ссылка на видео" type="video/mp4">
</video>
<!-- Сделала Fedyaeva http://front-test.tilda.ws/links ♥ -->
<script>
document.addEventListener("DOMContentLoaded", function() {
var lazyVideos = [].slice.call(document.querySelectorAll("video.lazy"));
if ("IntersectionObserver" in window) {
var lazyVideoObserver = new IntersectionObserver(function(entries, observer) {
entries.forEach(function(video) {
if (video.isIntersecting) {
for (var source in video.target.children) {
var videoSource = video.target.children[source];
if (typeof videoSource.tagName === "string" && videoSource.tagName === "SOURCE") {
videoSource.src = videoSource.dataset.src;
}
}
video.target.load();
video.target.classList.remove("lazy");
lazyVideoObserver.unobserve(video.target);
video.target.play();
}
else {
video.target.pause();
video.target.currentTime = 0;
}
});
});
lazyVideos.forEach(function(lazyVideo) {
lazyVideoObserver.observe(lazyVideo);
});
}
});
</script>