image-loading-lazy-in-viewport.html (562B)
1 <!DOCTYPE html> 2 3 <!-- This frame is used by image-loading-lazy-in-cross-origin-iframe-002.sub.html --> 4 5 <img id="img" loading="lazy"> 6 7 <script> 8 const img = document.querySelector('#img'); 9 10 // Prevent the list of available images check from loading the image non-lazily. 11 img.src = "image.png?image-loading-lazy-in-viewport-" + Math.random() + "-" + Date.now(); 12 13 img.addEventListener("load", () => { 14 parent.postMessage("image_loaded", "*"); 15 }); 16 17 window.addEventListener("load", () => { 18 parent.postMessage("window_loaded", "*"); 19 }); 20 </script>