1const check_webp_feature = (feature, callback) => { 2 var kTestImages = { 3 lossy: "UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA", 4 lossless: "UklGRhoAAABXRUJQVlA4TA0AAAAvAAAAEAcQERGIiP4HAA==", 5 alpha: "UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAARBxAR/Q9ERP8DAABWUDggGAAAABQBAJ0BKgEAAQAAAP4AAA3AAP7mtQAAAA==", 6 animation: "UklGRlIAAABXRUJQVlA4WAoAAAASAAAAAAAAAAAAQU5JTQYAAAD/////AABBTk1GJgAAAAAAAAAAAAAAAAAAAGQAAABWUDhMDQAAAC8AAAAQBxAREYiI/gcA" 7 }; 8 var img = new Image(); 9 img.onload = function () { 10 var result = (img.width > 0) && (img.height > 0); 11 callback(feature, result); 12 }; 13 img.onerror = function () { 14 callback(feature, false); 15 }; 16 img.src = "data:image/webp;base64," + kTestImages[feature]; 17} 18 19document.addEventListener('lazybeforeunveil', function (e) { 20 var bg = e.target.getAttribute('data-bg'); 21 var bgw = e.target.getAttribute('data-bgW'); 22 if (bg && !bgw) { 23 e.target.style.backgroundImage = 'url(' + bg + ')'; 24 } else if (bgw) { 25 if (window.supportsWebpDetected) { 26 if (window.supportsWebP) { 27 e.target.style.backgroundImage = 'url(' + bgw + ')'; 28 } else { 29 e.target.style.backgroundImage = 'url(' + bg + ')'; 30 } 31 } else { 32 check_webp_feature('lossy', (feature, status) => { 33 window.supportsWebpDetected = true; 34 window.supportsWebP = status; 35 if (window.supportsWebP) { 36 e.target.style.backgroundImage = 'url(' + bgw + ')'; 37 } else { 38 e.target.style.backgroundImage = 'url(' + bg + ')'; 39 } 40 }); 41 } 42 } 43}); 44 45document.addEventListener('lazyloaded', function (e) { 46 let _element = $(e.target); 47 48 _element.removeAttr('data-bg'); 49 _element.removeAttr('data-bgW'); 50 _element.removeAttr('data-src'); 51 52 let _picture = _element.closest('picture'); 53 if (_picture.length) { 54 _picture.removeAttr('style'); 55 _picture.find('[data-src]').removeAttr('data-src'); 56 _picture.find('[data-srcset]').removeAttr('data-srcset'); 57 } 58});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.