// snippets/Loading/Find-Images-With-Lazy-and-Fetchpriority.js | sha256:b9428aef89563d89 | https://github.com/nucliweb/webperf-snippets/blob/main/snippets/Loading/Find-Images-With-Lazy-and-Fetchpriority.js (()=>{function e(e){const t=e.getRootNode(),n=e=>{try{return 1===t.querySelectorAll(e).length}catch{return!1}},i=[];let r=e;for(;r&&1===r.nodeType;){if(r.id&&n(`#${window.CSS.escape(r.id)}`)){i.unshift(`#${window.CSS.escape(r.id)}`);break}const e=r.localName;let t=e+Array.from(r.classList).slice(0,2).map(e=>`.${window.CSS.escape(e)}`).join("");const o=r.parentNode?Array.from(r.parentNode.children):[r];if(o.filter(e=>e.matches(t)).length>1&&(t+=`:nth-of-type(${o.filter(t=>t.localName===e).indexOf(r)+1})`),i.unshift(t),n(i.join(" > ")))break;r=r.parentElement}return i.join(" > ")}function t(e){const t=e.getBoundingClientRect();return t.top0&&t.left0&&t.width>0&&t.height>0}const n=Array.from(document.querySelectorAll("img")).filter(e=>t(e)&&e.getBoundingClientRect().width>0);let i=null,r=0;n.forEach(e=>{const t=e.getBoundingClientRect(),n=t.width*t.height;n>r&&(r=n,i=e)});const o=document.querySelectorAll("[loading=lazy][fetchpriority=high]");if(0===o.length);else{const n=Array.from(o).map(n=>{const r=n.getBoundingClientRect(),o=t(n),c=n===i;return{selector:e(n),dimensions:`${Math.round(r.width)}×${Math.round(r.height)}`,inViewport:o?"Yes":"No",isLcpCandidate:c?"⚠️ Yes":"No",src:(n.currentSrc||n.src||"").slice(-50),element:n}});n.forEach(({},e)=>{}),n.forEach(({})=>{})}return{script:"Find-Images-With-Lazy-and-Fetchpriority",status:"ok",count:o.length,items:Array.from(o).map(n=>{const r=n.getBoundingClientRect();return{selector:e(n),src:n.currentSrc||n.src||"",inViewport:t(n),isLcpCandidate:n===i,widthPx:Math.round(r.width),heightPx:Math.round(r.height)}}),issues:o.length>0?[{code:"lazy-and-high-priority",severity:"error",message:`${o.length} element(s) have conflicting loading="lazy" and fetchpriority="high"`}]:[]}})();