File manager - Edit - /home/antilam/web/antilam.ru/public_html/wp-content/themes/woodmart/js/scripts/global/lcpTracker.min.js
Back
!function(){const e=[];new PerformanceObserver(t=>{for(const o of t.getEntries())"largest-contentful-paint"===o.entryType&&e.push(o)}).observe({type:"largest-contentful-paint",buffered:!0}),window.addEventListener("load",()=>{const t=document.querySelector(".wd-lcp-loader");function o(e="",t=!1,o=!0){return new Promise(n=>{const i=document.querySelector(".wd-lcp-admin-bar"),s=i.querySelector(".wd-lcp-desc"),c=i.querySelector(".wd-confirm"),a=i.querySelector(".wd-cancel"),r=i.querySelector(".wd-done");function d(){c.removeEventListener("click",l),a.removeEventListener("click",m)}function l(e){e.preventDefault(),d(),n(!0)}function m(e){e.preventDefault(),d(),n(!1)}e&&(s.textContent=e),i.classList.add("wd-opened"),!t&&(o||t||woodmart_settings.lcp_has_image)||(c.classList.add("wd-hide"),a.classList.add("wd-hide"),r.classList.remove("wd-hide")),o||t||woodmart_settings.lcp_has_image||r.addEventListener("click",m),c.addEventListener("click",l),a.addEventListener("click",m)})}t&&0!==e.length&&(t.classList.add("wd-loading"),setTimeout(()=>{if(t.classList.remove("wd-loading"),0===e.length)return;let n=null,i="",s=!1,c="",a="";const r=document.body.className.split(/\s+/),d=e[e.length-1].element,l=document.querySelector(".wd-lcp-admin-bar"),m=l.querySelector(".wd-loader-overlay");if(r.forEach(function(e){const t=e.match(/(?:page-id|postid)-(\d+)/);t&&(n=parseInt(t[1],10))}),n){if(["IMG","PICTURE"].includes(d.tagName))i=d.currentSrc||d.src,c="image",s="high"===d.getAttribute("fetchpriority");else{const e=getComputedStyle(d).backgroundImage;if(e&&e.includes("url")){const t=e.match(/url\(["']?(.*?)["']?\)/);t&&(i=t[1],c="background")}}if(i){d.classList.add("wd-lcp-highlight"),d.scrollIntoView({behavior:"smooth",block:"center"});const e=document.createElement("div"),t=document.createElement("img");t.src=i,e.appendChild(t),e.className="wd-lcp-thumb",l.querySelector(".wd-lcp-content").prepend(e),s?(a=woodmart_settings.lcp_image_with_fetchpriority,i=""):a=woodmart_settings.lcp_image_confirmed}else a=woodmart_settings.lcp_without_image_confirmed;o(a,!1,i).then(e=>{if(!e){d.classList.remove("wd-lcp-highlight");const e=window.location.origin+window.location.pathname;return window.history.replaceState({},document.title,e),l.classList.remove("wd-opened"),void l.classList.remove("hover")}m.classList.add("wd-loading");const t=new URLSearchParams(window.location.search).get("security");jQuery.ajax({url:woodmart_settings.ajaxurl,data:{action:"woodmart_update_lcp_image",image_url:i,image_type:c,post_id:n,security:t,device:768<=woodmartThemeModule.windowWidth?"desktop":"mobile"},dataType:"json",method:"GET",success:function(e){e.hasOwnProperty("data")&&(l.classList.add("wd-saved"),o(e.data.message,!0))},error:function(){console.error("Something wrong with AJAX response.")},complete:function(){const e=window.location.origin+window.location.pathname;window.history.replaceState({},document.title,e);const t=Array.from(l.children).filter(e=>e.classList&&e.classList.contains("ab-item"))[0];if(t){t.remove();const e=document.createElement("div");e.className="ab-item ab-empty-item",e.setAttribute("role","menuitem"),e.setAttribute("aria-expanded","false"),e.textContent="LCP Image",l.prepend(e)}m.classList.remove("wd-loading"),d.classList.remove("wd-lcp-highlight"),l.querySelector(".wd-done").addEventListener("click",e=>{e.preventDefault(),location.reload(),l.classList.remove("wd-saved"),l.classList.remove("wd-opened"),l.classList.remove("hover")})}})})}},2500))})}();
| ver. 1.4 |
Github
|
.
| PHP 8.4.22 | Generation time: 0.11 |
proxy
|
phpinfo
|
Settings