From 9497bb3e5feea5f8224b2870718acd17a9f67fb0 Mon Sep 17 00:00:00 2001 From: Gael Robin Date: Wed, 17 Jul 2024 04:08:15 +0200 Subject: [PATCH 01/13] Closes #6764: Refactor lcp beacon script Change the structure of the beacon script to include a new class `RocketBeacon` which will contains more generic functions that could be shared with other features. --- assets/js/lcp-beacon.min.js | 2 - assets/js/lcp-beacon.min.js.map | 1 - assets/js/{lcp-beacon.js => wpr-beacon.js} | 303 ++++++++++-------- assets/js/wpr-beacon.min.js | 2 + assets/js/wpr-beacon.min.js.map | 1 + dynamic-lists.json | 2 +- gulpfile.js | 4 +- .../Media/AboveTheFold/AJAX/Controller.php | 2 +- .../AboveTheFold/Frontend/Controller.php | 6 +- src/js/gulp/tasks/js.js | 4 +- .../AJAX/Controller/addLcpData.php | 36 +-- .../Subscriber/HTML/output_w_beacon.html | 2 +- .../AJAX/Controller/addLcpData.php | 2 +- 13 files changed, 194 insertions(+), 173 deletions(-) delete mode 100644 assets/js/lcp-beacon.min.js delete mode 100644 assets/js/lcp-beacon.min.js.map rename assets/js/{lcp-beacon.js => wpr-beacon.js} (69%) create mode 100644 assets/js/wpr-beacon.min.js create mode 100644 assets/js/wpr-beacon.min.js.map diff --git a/assets/js/lcp-beacon.min.js b/assets/js/lcp-beacon.min.js deleted file mode 100644 index 1eca46f9ff..0000000000 --- a/assets/js/lcp-beacon.min.js +++ /dev/null @@ -1,2 +0,0 @@ -!function n(r,s,o){function c(t,e){if(!s[t]){if(!r[t]){var i="function"==typeof require&&require;if(!e&&i)return i(t,!0);if(a)return a(t,!0);throw(e=new Error("Cannot find module '"+t+"'")).code="MODULE_NOT_FOUND",e}i=s[t]={exports:{}},r[t][0].call(i.exports,function(e){return c(r[t][1][e]||e)},i,i.exports,n,r,s,o)}return s[t].exports}for(var a="function"==typeof require&&require,e=0;e{this._handleInfiniteLoop()},1e4);try{var e=this._generateLcpCandidates(1/0);e&&(this._initWithFirstElementWithInfo(e),this._fillATFWithoutDuplications(e))}catch(e){this.errorCode="script_error",this._logMessage("Script Error: "+e)}this._saveFinalResultIntoDB()}else this._finalize()}async _isValidPreconditions(){return this._isNotValidScreensize()?(this._logMessage("Bailing out because screen size is not acceptable"),!1):!this._isPageCached()||!await this._isGeneratedBefore()||(this._logMessage("Bailing out because data is already available"),!1)}_isPageCached(){var e=document.documentElement.nextSibling&&document.documentElement.nextSibling.data?document.documentElement.nextSibling.data:"";return e&&e.includes("Debug: cached")}async _isGeneratedBefore(){var e=new FormData;return e.append("action","rocket_check_lcp"),e.append("rocket_lcp_nonce",this.config.nonce),e.append("url",this.config.url),e.append("is_mobile",this.config.is_mobile),(e=await fetch(this.config.ajax_url,{method:"POST",credentials:"same-origin",body:e}).then(e=>e.json())).success}_isNotValidScreensize(){var e=window.innerWidth||document.documentElement.clientWidth,t=window.innerHeight||document.documentElement.clientHeight,i=this.config.is_mobile&&(e>this.config.width_threshold||t>this.config.height_threshold),e=!this.config.is_mobile&&(e{if("img"===e.nodeName.toLowerCase()&&"picture"===e.parentElement.nodeName.toLowerCase())return null;let t;if("picture"===e.nodeName.toLowerCase()){var i=e.querySelector("img");if(!i)return null;t=i.getBoundingClientRect()}else t=e.getBoundingClientRect();return{element:e,rect:t}}).filter(e=>null!==e).filter(e=>0({item:e,area:this._getElementArea(e.rect),elementInfo:this._getElementInfo(e.element)})).sort((e,t)=>t.area-e.area).slice(0,e).map(e=>({element:e.item.element,elementInfo:e.elementInfo}))}_isIntersecting(e){return 0<=e.bottom&&0<=e.right&&e.top<=(window.innerHeight||document.documentElement.clientHeight)&&e.left<=(window.innerWidth||document.documentElement.clientWidth)}_getElementArea(e){return Math.min(e.width,(window.innerWidth||document.documentElement.clientWidth)-e.left)*Math.min(e.height,(window.innerHeight||document.documentElement.clientHeight)-e.top)}_getElementInfo(e){var t=e.nodeName.toLowerCase(),i={type:"",src:"",srcset:"",sizes:"",sources:[],bg_set:[],current_src:""};if("img"===t&&e.srcset)i.type="img-srcset",i.src=e.src,i.srcset=e.srcset,i.sizes=e.sizes,i.current_src=e.currentSrc;else if("img"===t)i.type="img",i.src=e.src,i.current_src=e.currentSrc;else if("video"===t){i.type="img";var n=e.querySelector("source");i.src=e.poster||(n?n.src:""),i.current_src=i.src}else if("svg"===t)(n=e.querySelector("image"))&&(i.type="img",i.src=n.getAttribute("href")||"",i.current_src=i.src);else if("picture"===t)i.type="picture",n=e.querySelector("img"),i.src=n?n.src:"",i.sources=Array.from(e.querySelectorAll("source")).map(e=>({srcset:e.srcset||"",media:e.media||"",type:e.type||"",sizes:e.sizes||""}));else{if(0===(t=[window.getComputedStyle(e,null).getPropertyValue("background-image"),getComputedStyle(e,":after").getPropertyValue("background-image"),getComputedStyle(e,":before").getPropertyValue("background-image")].filter(e=>"none"!==e)).length)return null;if(n=t[0],i.type="bg-img",n.includes("image-set(")&&(i.type="bg-img-set"),!n||""===n||n.includes("data:image"))return null;e=[...n.matchAll(/url\(\s*?['"]?\s*?(.+?)\s*?["']?\s*?\)/gi)],i.bg_set=e.map(e=>e[1]?{src:e[1].trim()+(e[2]?" "+e[2].trim():"")}:{}),i.bg_set.every(e=>""===e.src)&&(i.bg_set=e.map(e=>e[1]?{src:e[1].trim()}:{})),0null!==e.elementInfo))?this.performanceImages=[{...e.elementInfo,label:"lcp"}]:(this._logMessage("No LCP candidate found."),this.performanceImages=[])}_fillATFWithoutDuplications(e){e.forEach(e=>{var{element:e,elementInfo:t}=e;!this._isDuplicateImage(e)&&t&&this.performanceImages.push({...t,label:"above-the-fold"})})}_isDuplicateImage(e){const t=this._getElementInfo(e);var i;return null!==t&&(e="img"===t.type||"img-srcset"===t.type||"video"===t.type,i="bg-img"===t.type||"bg-img-set"===t.type||"picture"===t.type,e||i)&&this.performanceImages.some(e=>e.src===t.src)}_getFinalStatus(){return""!==this.errorCode?this.errorCode:10<=(new Date-this.scriptTimer)/1e3?"timeout":"success"}_saveFinalResultIntoDB(){var e=new FormData;e.append("action","rocket_lcp"),e.append("rocket_lcp_nonce",this.config.nonce),e.append("url",this.config.url),e.append("is_mobile",this.config.is_mobile),e.append("images",JSON.stringify(this.performanceImages)),e.append("status",this._getFinalStatus()),fetch(this.config.ajax_url,{method:"POST",credentials:"same-origin",body:e,headers:{"wpr-saas-no-intercept":!0}}).then(e=>e.json()).then(e=>{this._logMessage(e)}).catch(e=>{this._logMessage(e)}).finally(()=>{this._finalize()})}_handleInfiniteLoop(){this._saveFinalResultIntoDB()}_finalize(){document.querySelector('[data-name="wpr-lcp-beacon"]').setAttribute("beacon-completed","true"),clearTimeout(this.infiniteLoopId)}_logMessage(e){this.config.debug&&console.log(e)}static run(){if(window.rocket_lcp_data){const e=new n(window.rocket_lcp_data);"loading"!==document.readyState?setTimeout(()=>{e.init()},window.rocket_lcp_data.delay):document.addEventListener("DOMContentLoaded",()=>{setTimeout(()=>{e.init()},window.rocket_lcp_data.delay)})}}}).run()},{}]},{},[1]); -//# sourceMappingURL=lcp-beacon.min.js.map diff --git a/assets/js/lcp-beacon.min.js.map b/assets/js/lcp-beacon.min.js.map deleted file mode 100644 index 3db9f48fc2..0000000000 --- a/assets/js/lcp-beacon.min.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"names":[],"mappings":"","sources":["lcp-beacon.min.js"],"sourcesContent":["!function n(r,s,o){function c(t,e){if(!s[t]){if(!r[t]){var i=\"function\"==typeof require&&require;if(!e&&i)return i(t,!0);if(a)return a(t,!0);throw(e=new Error(\"Cannot find module '\"+t+\"'\")).code=\"MODULE_NOT_FOUND\",e}i=s[t]={exports:{}},r[t][0].call(i.exports,function(e){return c(r[t][1][e]||e)},i,i.exports,n,r,s,o)}return s[t].exports}for(var a=\"function\"==typeof require&&require,e=0;e{this._handleInfiniteLoop()},1e4);try{var e=this._generateLcpCandidates(1/0);e&&(this._initWithFirstElementWithInfo(e),this._fillATFWithoutDuplications(e))}catch(e){this.errorCode=\"script_error\",this._logMessage(\"Script Error: \"+e)}this._saveFinalResultIntoDB()}else this._finalize()}async _isValidPreconditions(){return this._isNotValidScreensize()?(this._logMessage(\"Bailing out because screen size is not acceptable\"),!1):!this._isPageCached()||!await this._isGeneratedBefore()||(this._logMessage(\"Bailing out because data is already available\"),!1)}_isPageCached(){var e=document.documentElement.nextSibling&&document.documentElement.nextSibling.data?document.documentElement.nextSibling.data:\"\";return e&&e.includes(\"Debug: cached\")}async _isGeneratedBefore(){var e=new FormData;return e.append(\"action\",\"rocket_check_lcp\"),e.append(\"rocket_lcp_nonce\",this.config.nonce),e.append(\"url\",this.config.url),e.append(\"is_mobile\",this.config.is_mobile),(e=await fetch(this.config.ajax_url,{method:\"POST\",credentials:\"same-origin\",body:e}).then(e=>e.json())).success}_isNotValidScreensize(){var e=window.innerWidth||document.documentElement.clientWidth,t=window.innerHeight||document.documentElement.clientHeight,i=this.config.is_mobile&&(e>this.config.width_threshold||t>this.config.height_threshold),e=!this.config.is_mobile&&(e{if(\"img\"===e.nodeName.toLowerCase()&&\"picture\"===e.parentElement.nodeName.toLowerCase())return null;let t;if(\"picture\"===e.nodeName.toLowerCase()){var i=e.querySelector(\"img\");if(!i)return null;t=i.getBoundingClientRect()}else t=e.getBoundingClientRect();return{element:e,rect:t}}).filter(e=>null!==e).filter(e=>0({item:e,area:this._getElementArea(e.rect),elementInfo:this._getElementInfo(e.element)})).sort((e,t)=>t.area-e.area).slice(0,e).map(e=>({element:e.item.element,elementInfo:e.elementInfo}))}_isIntersecting(e){return 0<=e.bottom&&0<=e.right&&e.top<=(window.innerHeight||document.documentElement.clientHeight)&&e.left<=(window.innerWidth||document.documentElement.clientWidth)}_getElementArea(e){return Math.min(e.width,(window.innerWidth||document.documentElement.clientWidth)-e.left)*Math.min(e.height,(window.innerHeight||document.documentElement.clientHeight)-e.top)}_getElementInfo(e){var t=e.nodeName.toLowerCase(),i={type:\"\",src:\"\",srcset:\"\",sizes:\"\",sources:[],bg_set:[],current_src:\"\"};if(\"img\"===t&&e.srcset)i.type=\"img-srcset\",i.src=e.src,i.srcset=e.srcset,i.sizes=e.sizes,i.current_src=e.currentSrc;else if(\"img\"===t)i.type=\"img\",i.src=e.src,i.current_src=e.currentSrc;else if(\"video\"===t){i.type=\"img\";var n=e.querySelector(\"source\");i.src=e.poster||(n?n.src:\"\"),i.current_src=i.src}else if(\"svg\"===t)(n=e.querySelector(\"image\"))&&(i.type=\"img\",i.src=n.getAttribute(\"href\")||\"\",i.current_src=i.src);else if(\"picture\"===t)i.type=\"picture\",n=e.querySelector(\"img\"),i.src=n?n.src:\"\",i.sources=Array.from(e.querySelectorAll(\"source\")).map(e=>({srcset:e.srcset||\"\",media:e.media||\"\",type:e.type||\"\",sizes:e.sizes||\"\"}));else{if(0===(t=[window.getComputedStyle(e,null).getPropertyValue(\"background-image\"),getComputedStyle(e,\":after\").getPropertyValue(\"background-image\"),getComputedStyle(e,\":before\").getPropertyValue(\"background-image\")].filter(e=>\"none\"!==e)).length)return null;if(n=t[0],i.type=\"bg-img\",n.includes(\"image-set(\")&&(i.type=\"bg-img-set\"),!n||\"\"===n||n.includes(\"data:image\"))return null;e=[...n.matchAll(/url\\(\\s*?['\"]?\\s*?(.+?)\\s*?[\"']?\\s*?\\)/gi)],i.bg_set=e.map(e=>e[1]?{src:e[1].trim()+(e[2]?\" \"+e[2].trim():\"\")}:{}),i.bg_set.every(e=>\"\"===e.src)&&(i.bg_set=e.map(e=>e[1]?{src:e[1].trim()}:{})),0null!==e.elementInfo))?this.performanceImages=[{...e.elementInfo,label:\"lcp\"}]:(this._logMessage(\"No LCP candidate found.\"),this.performanceImages=[])}_fillATFWithoutDuplications(e){e.forEach(e=>{var{element:e,elementInfo:t}=e;!this._isDuplicateImage(e)&&t&&this.performanceImages.push({...t,label:\"above-the-fold\"})})}_isDuplicateImage(e){const t=this._getElementInfo(e);var i;return null!==t&&(e=\"img\"===t.type||\"img-srcset\"===t.type||\"video\"===t.type,i=\"bg-img\"===t.type||\"bg-img-set\"===t.type||\"picture\"===t.type,e||i)&&this.performanceImages.some(e=>e.src===t.src)}_getFinalStatus(){return\"\"!==this.errorCode?this.errorCode:10<=(new Date-this.scriptTimer)/1e3?\"timeout\":\"success\"}_saveFinalResultIntoDB(){var e=new FormData;e.append(\"action\",\"rocket_lcp\"),e.append(\"rocket_lcp_nonce\",this.config.nonce),e.append(\"url\",this.config.url),e.append(\"is_mobile\",this.config.is_mobile),e.append(\"images\",JSON.stringify(this.performanceImages)),e.append(\"status\",this._getFinalStatus()),fetch(this.config.ajax_url,{method:\"POST\",credentials:\"same-origin\",body:e,headers:{\"wpr-saas-no-intercept\":!0}}).then(e=>e.json()).then(e=>{this._logMessage(e)}).catch(e=>{this._logMessage(e)}).finally(()=>{this._finalize()})}_handleInfiniteLoop(){this._saveFinalResultIntoDB()}_finalize(){document.querySelector('[data-name=\"wpr-lcp-beacon\"]').setAttribute(\"beacon-completed\",\"true\"),clearTimeout(this.infiniteLoopId)}_logMessage(e){this.config.debug&&console.log(e)}static run(){if(window.rocket_lcp_data){const e=new n(window.rocket_lcp_data);\"loading\"!==document.readyState?setTimeout(()=>{e.init()},window.rocket_lcp_data.delay):document.addEventListener(\"DOMContentLoaded\",()=>{setTimeout(()=>{e.init()},window.rocket_lcp_data.delay)})}}}).run()},{}]},{},[1]);"],"file":"lcp-beacon.min.js"} \ No newline at end of file diff --git a/assets/js/lcp-beacon.js b/assets/js/wpr-beacon.js similarity index 69% rename from assets/js/lcp-beacon.js rename to assets/js/wpr-beacon.js index 9150860ba3..2d5590a191 100644 --- a/assets/js/lcp-beacon.js +++ b/assets/js/wpr-beacon.js @@ -1,45 +1,39 @@ -class RocketLcpBeacon { - constructor( config ) { - this.config = config; - this.performanceImages = []; - this.errorCode = ''; - this.scriptTimer = new Date(); - this.infiniteLoopId = null; +class RocketBeacon { + constructor(config) { + this.config = config; + this.lcpBeacon = null; + this.infiniteLoopId = null; + this.scriptTimer = new Date(); + this.errorCode = ''; } async init() { - if ( ! await this._isValidPreconditions() ) { + if (!await this._isValidPreconditions()) { this._finalize(); return; } - this.infiniteLoopId = setTimeout( () => { + this.infiniteLoopId = setTimeout(() => { this._handleInfiniteLoop(); - }, 10000 ); + }, 10000); - try { - // Use _generateLcpCandidates method to get all the elements in the viewport. - const above_the_fold_images = this._generateLcpCandidates( Infinity ); - if ( above_the_fold_images ) { - this._initWithFirstElementWithInfo( above_the_fold_images ); - this._fillATFWithoutDuplications( above_the_fold_images ); - } - } catch ( err ) { - this.errorCode = 'script_error'; - this._logMessage( 'Script Error: ' + err ); + const isGeneratedBefore = await this._isGeneratedBefore(); + + if (!isGeneratedBefore.lcp) { + this.lcpBeacon = new RocketLcpBeacon(this.config); + await this.lcpBeacon.run(); } this._saveFinalResultIntoDB(); } async _isValidPreconditions() { - // Check the screensize first because starting any logic. - if ( this._isNotValidScreensize() ) { + if (this._isNotValidScreensize()) { this._logMessage('Bailing out because screen size is not acceptable'); return false; } - if ( this._isPageCached() && await this._isGeneratedBefore() ) { + if (this._isPageCached() && await this._isGeneratedBefore()) { this._logMessage('Bailing out because data is already available'); return false; } @@ -49,52 +43,161 @@ class RocketLcpBeacon { _isPageCached() { const signature = document.documentElement.nextSibling && document.documentElement.nextSibling.data ? document.documentElement.nextSibling.data : ''; - - return signature && signature.includes( 'Debug: cached' ); + return signature && signature.includes('Debug: cached'); } async _isGeneratedBefore() { - // AJAX call to check if there are any records for the current URL. let data_check = new FormData(); data_check.append('action', 'rocket_check_lcp'); data_check.append('rocket_lcp_nonce', this.config.nonce); data_check.append('url', this.config.url); data_check.append('is_mobile', this.config.is_mobile); - const lcp_data_response = await fetch(this.config.ajax_url, { - method: "POST", - credentials: 'same-origin', - body: data_check - }) - .then(data => data.json()); - return lcp_data_response.success; + const beacon_data_response = await fetch(this.config.ajax_url, { + method: "POST", + credentials: 'same-origin', + body: data_check + }).then(data => data.json()); + + return beacon_data_response.data; } _isNotValidScreensize() { - // Check screen size const screenWidth = window.innerWidth || document.documentElement.clientWidth; - const screenHeight= window.innerHeight || document.documentElement.clientHeight; + const screenHeight = window.innerHeight || document.documentElement.clientHeight; const isNotValidForMobile = this.config.is_mobile && - ( screenWidth > this.config.width_threshold || screenHeight > this.config.height_threshold ); + (screenWidth > this.config.width_threshold || screenHeight > this.config.height_threshold); const isNotValidForDesktop = !this.config.is_mobile && - ( screenWidth < this.config.width_threshold || screenHeight < this.config.height_threshold ); + (screenWidth < this.config.width_threshold || screenHeight < this.config.height_threshold); return isNotValidForMobile || isNotValidForDesktop; } - _generateLcpCandidates( count ) { - const lcpElements = document.querySelectorAll( this.config.elements ); + static _isIntersecting(rect) { + return ( + rect.bottom >= 0 && + rect.right >= 0 && + rect.top <= (window.innerHeight || document.documentElement.clientHeight) && + rect.left <= (window.innerWidth || document.documentElement.clientWidth) + ); + } + + _saveFinalResultIntoDB() { + const lcpResults = this.lcpBeacon ? this.lcpBeacon.getResults() : null; + + const data = new FormData(); + data.append('action', 'rocket_lcp'); + data.append('rocket_lcp_nonce', this.config.nonce); + data.append('url', this.config.url); + data.append('is_mobile', this.config.is_mobile); + data.append('status', this._getFinalStatus()); + data.append('lcp_images', JSON.stringify(lcpResults)); + + fetch(this.config.ajax_url, { + method: "POST", + credentials: 'same-origin', + body: data, + headers: { + 'wpr-saas-no-intercept': true + } + }) + .then(response => response.json()) + .then(data => { + this._logMessage(data); + }) + .catch(error => { + this._logMessage(error); + }) + .finally(() => { + this._finalize(); + }); + } + + _getFinalStatus() { + if ('' !== this.errorCode) { + return this.errorCode; + } + + const scriptTime = (new Date() - this.scriptTimer) / 1000; + if (10 <= scriptTime) { + return 'timeout'; + } + + return 'success'; + } + + _handleInfiniteLoop() { + this._saveFinalResultIntoDB(); + } + + _finalize() { + const beaconscript = document.querySelector('[data-name="wpr-wpr-beacon"]'); + beaconscript.setAttribute('beacon-completed', 'true'); + clearTimeout(this.infiniteLoopId); + } + + _logMessage(msg) { + if (!this.config.debug) { + return; + } + console.log(msg); + } + + static run() { + if (!window.rocket_lcp_data) { + return; + } + + const instance = new RocketBeacon(window.rocket_lcp_data); + + if (document.readyState !== 'loading') { + setTimeout(() => { + instance.init(); + }, window.rocket_lcp_data.delay); + return; + } + + document.addEventListener("DOMContentLoaded", () => { + setTimeout(() => { + instance.init(); + }, window.rocket_lcp_data.delay); + }); + } +} + - if ( lcpElements.length <= 0 ) { +class RocketLcpBeacon { + constructor(config) { + this.config = config; + this.performanceImages = []; + this.errorCode = ''; + } + + async run() { + try { + const above_the_fold_images = this._generateLcpCandidates(Infinity); + if (above_the_fold_images) { + this._initWithFirstElementWithInfo(above_the_fold_images); + this._fillATFWithoutDuplications(above_the_fold_images); + } + } catch (err) { + this.errorCode = 'script_error'; + this._logMessage('Script Error: ' + err); + } + } + + _generateLcpCandidates(count) { + const lcpElements = document.querySelectorAll(this.config.elements); + + if (lcpElements.length <= 0) { return []; } - const potentialCandidates = Array.from( lcpElements ); + const potentialCandidates = Array.from(lcpElements); const topCandidates = potentialCandidates.map(element => { - // Skip if the element is an img and its parent is a picture - if ('img' === element.nodeName.toLowerCase() && 'picture' === element.parentElement.nodeName.toLowerCase() ) { + if ('img' === element.nodeName.toLowerCase() && 'picture' === element.parentElement.nodeName.toLowerCase()) { return null; } let rect; @@ -114,12 +217,12 @@ class RocketLcpBeacon { rect: rect, }; }) - .filter(item => item !== null) // Filter out null values here + .filter(item => item !== null) .filter(item => { return ( item.rect.width > 0 && item.rect.height > 0 && - this._isIntersecting(item.rect) + RocketBeacon._isIntersecting(item.rect) ); }) .map(item => ({ @@ -136,16 +239,6 @@ class RocketLcpBeacon { })); } - _isIntersecting(rect) { - // Check if any part of the image is within the viewport - return ( - rect.bottom >= 0 && - rect.right >= 0 && - rect.top <= (window.innerHeight || document.documentElement.clientHeight) && - rect.left <= (window.innerWidth || document.documentElement.clientWidth) - ); - } - _getElementArea(rect) { const visibleWidth = Math.min(rect.width, (window.innerWidth || document.documentElement.clientWidth) - rect.left); const visibleHeight = Math.min(rect.height, (window.innerHeight || document.documentElement.clientHeight) - rect.top); @@ -170,8 +263,8 @@ class RocketLcpBeacon { if (nodeName === "img" && element.srcset) { element_info.type = "img-srcset"; element_info.src = element.src; - element_info.srcset = element.srcset; // capture srcset - element_info.sizes = element.sizes; // capture sizes + element_info.srcset = element.srcset; + element_info.sizes = element.sizes; element_info.current_src = element.currentSrc; } else if (nodeName === "img") { element_info.type = "img"; @@ -215,16 +308,14 @@ class RocketLcpBeacon { if (full_bg_prop.includes("image-set(")) { element_info.type = "bg-img-set"; } - if (!full_bg_prop || full_bg_prop === "" || full_bg_prop.includes( 'data:image' ) ) { + if (!full_bg_prop || full_bg_prop === "" || full_bg_prop.includes('data:image')) { return null; } const matches = [...full_bg_prop.matchAll(css_bg_url_rgx)]; - element_info.bg_set = matches.map(m => m[1] ? {src: m[1].trim() + (m[2] ? " " + m[2].trim() : "")} : {}); - // Check if bg_set array is populated with empty objects + element_info.bg_set = matches.map(m => m[1] ? { src: m[1].trim() + (m[2] ? " " + m[2].trim() : "") } : {}); if (element_info.bg_set.every(item => item.src === "")) { - // If bg_set array is populated with empty objects, populate it with the URLs from the matches array - element_info.bg_set = matches.map(m => m[1] ? {src: m[1].trim()} : {}); + element_info.bg_set = matches.map(m => m[1] ? { src: m[1].trim() } : {}); } if (element_info.bg_set.length > 0) { @@ -241,7 +332,7 @@ class RocketLcpBeacon { _initWithFirstElementWithInfo(elements) { const firstElementWithInfo = elements.find(item => item.elementInfo !== null); - if ( ! firstElementWithInfo ) { + if (!firstElementWithInfo) { this._logMessage("No LCP candidate found."); this.performanceImages = []; return; @@ -255,7 +346,7 @@ class RocketLcpBeacon { _fillATFWithoutDuplications(elements) { elements.forEach(({ element, elementInfo }) => { - if ( this._isDuplicateImage(element) || !elementInfo ) { + if (this._isDuplicateImage(element) || !elementInfo) { return; } @@ -280,90 +371,20 @@ class RocketLcpBeacon { elementInfo.type === "bg-img-set" || elementInfo.type === "picture"; - return (isImageOrVideo || isBgImageOrPicture) - && + return (isImageOrVideo || isBgImageOrPicture) && this.performanceImages.some(item => item.src === elementInfo.src); } - _getFinalStatus() { - if ( '' !== this.errorCode ) { - return this.errorCode; - } - - const scriptTime = ( new Date() - this.scriptTimer ) / 1000; - if ( 10 <= scriptTime ) { - return 'timeout'; - } - - return 'success'; - } - - _saveFinalResultIntoDB() { - const data = new FormData(); - data.append('action', 'rocket_lcp'); - data.append('rocket_lcp_nonce', this.config.nonce); - data.append('url', this.config.url); - data.append('is_mobile', this.config.is_mobile); - data.append('images', JSON.stringify(this.performanceImages)); - data.append('status', this._getFinalStatus()); - - fetch(this.config.ajax_url, { - method: "POST", - credentials: 'same-origin', - body: data, - headers: { - 'wpr-saas-no-intercept': true - } - }) - .then((response) => response.json()) - .then((data) => { - this._logMessage(data); - }) - .catch((error) => { - this._logMessage(error); - }) - .finally(() => { - this._finalize(); - }); - } - - _handleInfiniteLoop() { - this._saveFinalResultIntoDB(); - } - - _finalize() { - const beaconscript = document.querySelector('[data-name="wpr-lcp-beacon"]'); - beaconscript.setAttribute('beacon-completed', 'true'); - clearTimeout( this.infiniteLoopId ); - } - - _logMessage( msg ) { - if ( ! this.config.debug ) { + _logMessage(msg) { + if (!this.config.debug) { return; } - console.log( msg ); + console.log(msg); } - static run() { - if ( !window.rocket_lcp_data ) { - return; - } - - const instance = new RocketLcpBeacon( window.rocket_lcp_data ); - - if (document.readyState !== 'loading') { - setTimeout(() => { - instance.init(); - }, window.rocket_lcp_data.delay); - return; - } - - document.addEventListener("DOMContentLoaded", () => { - setTimeout(() => { - instance.init(); - }, window.rocket_lcp_data.delay); - }); + getResults() { + return this.performanceImages; } } -RocketLcpBeacon.run(); +RocketBeacon.run(); \ No newline at end of file diff --git a/assets/js/wpr-beacon.min.js b/assets/js/wpr-beacon.min.js new file mode 100644 index 0000000000..763122d3d3 --- /dev/null +++ b/assets/js/wpr-beacon.min.js @@ -0,0 +1,2 @@ +!function n(r,s,o){function c(t,e){if(!s[t]){if(!r[t]){var i="function"==typeof require&&require;if(!e&&i)return i(t,!0);if(a)return a(t,!0);throw(e=new Error("Cannot find module '"+t+"'")).code="MODULE_NOT_FOUND",e}i=s[t]={exports:{}},r[t][0].call(i.exports,function(e){return c(r[t][1][e]||e)},i,i.exports,n,r,s,o)}return s[t].exports}for(var a="function"==typeof require&&require,e=0;e{this._handleInfiniteLoop()},1e4),(await this._isGeneratedBefore()).lcp||(this.lcpBeacon=new r(this.config),await this.lcpBeacon.run()),this._saveFinalResultIntoDB()):this._finalize()}async _isValidPreconditions(){return this._isNotValidScreensize()?(this._logMessage("Bailing out because screen size is not acceptable"),!1):!this._isPageCached()||!await this._isGeneratedBefore()||(this._logMessage("Bailing out because data is already available"),!1)}_isPageCached(){var e=document.documentElement.nextSibling&&document.documentElement.nextSibling.data?document.documentElement.nextSibling.data:"";return e&&e.includes("Debug: cached")}async _isGeneratedBefore(){var e=new FormData,e=(e.append("action","rocket_check_lcp"),e.append("rocket_lcp_nonce",this.config.nonce),e.append("url",this.config.url),e.append("is_mobile",this.config.is_mobile),await fetch(this.config.ajax_url,{method:"POST",credentials:"same-origin",body:e}).then(e=>e.json()));return e.data}_isNotValidScreensize(){var e=window.innerWidth||document.documentElement.clientWidth,t=window.innerHeight||document.documentElement.clientHeight,i=this.config.is_mobile&&(e>this.config.width_threshold||t>this.config.height_threshold),e=!this.config.is_mobile&&(ee.json()).then(e=>{this._logMessage(e)}).catch(e=>{this._logMessage(e)}).finally(()=>{this._finalize()})}_getFinalStatus(){return""!==this.errorCode?this.errorCode:10<=(new Date-this.scriptTimer)/1e3?"timeout":"success"}_handleInfiniteLoop(){this._saveFinalResultIntoDB()}_finalize(){document.querySelector('[data-name="wpr-wpr-beacon"]').setAttribute("beacon-completed","true"),clearTimeout(this.infiniteLoopId)}_logMessage(e){this.config.debug&&console.log(e)}static run(){if(window.rocket_lcp_data){let e=new n(window.rocket_lcp_data);"loading"!==document.readyState?setTimeout(()=>{e.init()},window.rocket_lcp_data.delay):document.addEventListener("DOMContentLoaded",()=>{setTimeout(()=>{e.init()},window.rocket_lcp_data.delay)})}}}class r{constructor(e){this.config=e,this.performanceImages=[],this.errorCode=""}async run(){try{var e=this._generateLcpCandidates(1/0);e&&(this._initWithFirstElementWithInfo(e),this._fillATFWithoutDuplications(e))}catch(e){this.errorCode="script_error",this._logMessage("Script Error: "+e)}}_generateLcpCandidates(e){var t=document.querySelectorAll(this.config.elements);return t.length<=0?[]:Array.from(t).map(e=>{if("img"===e.nodeName.toLowerCase()&&"picture"===e.parentElement.nodeName.toLowerCase())return null;let t;if("picture"===e.nodeName.toLowerCase()){var i=e.querySelector("img");if(!i)return null;t=i.getBoundingClientRect()}else t=e.getBoundingClientRect();return{element:e,rect:t}}).filter(e=>null!==e).filter(e=>0({item:e,area:this._getElementArea(e.rect),elementInfo:this._getElementInfo(e.element)})).sort((e,t)=>t.area-e.area).slice(0,e).map(e=>({element:e.item.element,elementInfo:e.elementInfo}))}_getElementArea(e){return Math.min(e.width,(window.innerWidth||document.documentElement.clientWidth)-e.left)*Math.min(e.height,(window.innerHeight||document.documentElement.clientHeight)-e.top)}_getElementInfo(e){var t=e.nodeName.toLowerCase(),i={type:"",src:"",srcset:"",sizes:"",sources:[],bg_set:[],current_src:""};if("img"===t&&e.srcset)i.type="img-srcset",i.src=e.src,i.srcset=e.srcset,i.sizes=e.sizes,i.current_src=e.currentSrc;else if("img"===t)i.type="img",i.src=e.src,i.current_src=e.currentSrc;else if("video"===t){i.type="img";var n=e.querySelector("source");i.src=e.poster||(n?n.src:""),i.current_src=i.src}else if("svg"===t){n=e.querySelector("image");n&&(i.type="img",i.src=n.getAttribute("href")||"",i.current_src=i.src)}else if("picture"===t){i.type="picture";n=e.querySelector("img");i.src=n?n.src:"",i.sources=Array.from(e.querySelectorAll("source")).map(e=>({srcset:e.srcset||"",media:e.media||"",type:e.type||"",sizes:e.sizes||""}))}else{t=[window.getComputedStyle(e,null).getPropertyValue("background-image"),getComputedStyle(e,":after").getPropertyValue("background-image"),getComputedStyle(e,":before").getPropertyValue("background-image")].filter(e=>"none"!==e);if(0===t.length)return null;n=t[0];if(i.type="bg-img",n.includes("image-set(")&&(i.type="bg-img-set"),!n||""===n||n.includes("data:image"))return null;e=[...n.matchAll(/url\(\s*?['"]?\s*?(.+?)\s*?["']?\s*?\)/gi)];i.bg_set=e.map(e=>e[1]?{src:e[1].trim()+(e[2]?" "+e[2].trim():"")}:{}),i.bg_set.every(e=>""===e.src)&&(i.bg_set=e.map(e=>e[1]?{src:e[1].trim()}:{})),0null!==e.elementInfo);e?this.performanceImages=[{...e.elementInfo,label:"lcp"}]:(this._logMessage("No LCP candidate found."),this.performanceImages=[])}_fillATFWithoutDuplications(e){e.forEach(e=>{var{element:e,elementInfo:t}=e;!this._isDuplicateImage(e)&&t&&this.performanceImages.push({...t,label:"above-the-fold"})})}_isDuplicateImage(e){let t=this._getElementInfo(e);var i;return null!==t&&(e="img"===t.type||"img-srcset"===t.type||"video"===t.type,i="bg-img"===t.type||"bg-img-set"===t.type||"picture"===t.type,e||i)&&this.performanceImages.some(e=>e.src===t.src)}_logMessage(e){this.config.debug&&console.log(e)}getResults(){return this.performanceImages}}n.run()},{}]},{},[1]); +//# sourceMappingURL=wpr-beacon.min.js.map diff --git a/assets/js/wpr-beacon.min.js.map b/assets/js/wpr-beacon.min.js.map new file mode 100644 index 0000000000..17d8ecf9b1 --- /dev/null +++ b/assets/js/wpr-beacon.min.js.map @@ -0,0 +1 @@ +{"version":3,"names":[],"mappings":"","sources":["wpr-beacon.min.js"],"sourcesContent":["!function n(r,s,o){function c(t,e){if(!s[t]){if(!r[t]){var i=\"function\"==typeof require&&require;if(!e&&i)return i(t,!0);if(a)return a(t,!0);throw(e=new Error(\"Cannot find module '\"+t+\"'\")).code=\"MODULE_NOT_FOUND\",e}i=s[t]={exports:{}},r[t][0].call(i.exports,function(e){return c(r[t][1][e]||e)},i,i.exports,n,r,s,o)}return s[t].exports}for(var a=\"function\"==typeof require&&require,e=0;e{this._handleInfiniteLoop()},1e4),(await this._isGeneratedBefore()).lcp||(this.lcpBeacon=new r(this.config),await this.lcpBeacon.run()),this._saveFinalResultIntoDB()):this._finalize()}async _isValidPreconditions(){return this._isNotValidScreensize()?(this._logMessage(\"Bailing out because screen size is not acceptable\"),!1):!this._isPageCached()||!await this._isGeneratedBefore()||(this._logMessage(\"Bailing out because data is already available\"),!1)}_isPageCached(){var e=document.documentElement.nextSibling&&document.documentElement.nextSibling.data?document.documentElement.nextSibling.data:\"\";return e&&e.includes(\"Debug: cached\")}async _isGeneratedBefore(){var e=new FormData,e=(e.append(\"action\",\"rocket_check_lcp\"),e.append(\"rocket_lcp_nonce\",this.config.nonce),e.append(\"url\",this.config.url),e.append(\"is_mobile\",this.config.is_mobile),await fetch(this.config.ajax_url,{method:\"POST\",credentials:\"same-origin\",body:e}).then(e=>e.json()));return e.data}_isNotValidScreensize(){var e=window.innerWidth||document.documentElement.clientWidth,t=window.innerHeight||document.documentElement.clientHeight,i=this.config.is_mobile&&(e>this.config.width_threshold||t>this.config.height_threshold),e=!this.config.is_mobile&&(ee.json()).then(e=>{this._logMessage(e)}).catch(e=>{this._logMessage(e)}).finally(()=>{this._finalize()})}_getFinalStatus(){return\"\"!==this.errorCode?this.errorCode:10<=(new Date-this.scriptTimer)/1e3?\"timeout\":\"success\"}_handleInfiniteLoop(){this._saveFinalResultIntoDB()}_finalize(){document.querySelector('[data-name=\"wpr-wpr-beacon\"]').setAttribute(\"beacon-completed\",\"true\"),clearTimeout(this.infiniteLoopId)}_logMessage(e){this.config.debug&&console.log(e)}static run(){if(window.rocket_lcp_data){let e=new n(window.rocket_lcp_data);\"loading\"!==document.readyState?setTimeout(()=>{e.init()},window.rocket_lcp_data.delay):document.addEventListener(\"DOMContentLoaded\",()=>{setTimeout(()=>{e.init()},window.rocket_lcp_data.delay)})}}}class r{constructor(e){this.config=e,this.performanceImages=[],this.errorCode=\"\"}async run(){try{var e=this._generateLcpCandidates(1/0);e&&(this._initWithFirstElementWithInfo(e),this._fillATFWithoutDuplications(e))}catch(e){this.errorCode=\"script_error\",this._logMessage(\"Script Error: \"+e)}}_generateLcpCandidates(e){var t=document.querySelectorAll(this.config.elements);return t.length<=0?[]:Array.from(t).map(e=>{if(\"img\"===e.nodeName.toLowerCase()&&\"picture\"===e.parentElement.nodeName.toLowerCase())return null;let t;if(\"picture\"===e.nodeName.toLowerCase()){var i=e.querySelector(\"img\");if(!i)return null;t=i.getBoundingClientRect()}else t=e.getBoundingClientRect();return{element:e,rect:t}}).filter(e=>null!==e).filter(e=>0({item:e,area:this._getElementArea(e.rect),elementInfo:this._getElementInfo(e.element)})).sort((e,t)=>t.area-e.area).slice(0,e).map(e=>({element:e.item.element,elementInfo:e.elementInfo}))}_getElementArea(e){return Math.min(e.width,(window.innerWidth||document.documentElement.clientWidth)-e.left)*Math.min(e.height,(window.innerHeight||document.documentElement.clientHeight)-e.top)}_getElementInfo(e){var t=e.nodeName.toLowerCase(),i={type:\"\",src:\"\",srcset:\"\",sizes:\"\",sources:[],bg_set:[],current_src:\"\"};if(\"img\"===t&&e.srcset)i.type=\"img-srcset\",i.src=e.src,i.srcset=e.srcset,i.sizes=e.sizes,i.current_src=e.currentSrc;else if(\"img\"===t)i.type=\"img\",i.src=e.src,i.current_src=e.currentSrc;else if(\"video\"===t){i.type=\"img\";var n=e.querySelector(\"source\");i.src=e.poster||(n?n.src:\"\"),i.current_src=i.src}else if(\"svg\"===t){n=e.querySelector(\"image\");n&&(i.type=\"img\",i.src=n.getAttribute(\"href\")||\"\",i.current_src=i.src)}else if(\"picture\"===t){i.type=\"picture\";n=e.querySelector(\"img\");i.src=n?n.src:\"\",i.sources=Array.from(e.querySelectorAll(\"source\")).map(e=>({srcset:e.srcset||\"\",media:e.media||\"\",type:e.type||\"\",sizes:e.sizes||\"\"}))}else{t=[window.getComputedStyle(e,null).getPropertyValue(\"background-image\"),getComputedStyle(e,\":after\").getPropertyValue(\"background-image\"),getComputedStyle(e,\":before\").getPropertyValue(\"background-image\")].filter(e=>\"none\"!==e);if(0===t.length)return null;n=t[0];if(i.type=\"bg-img\",n.includes(\"image-set(\")&&(i.type=\"bg-img-set\"),!n||\"\"===n||n.includes(\"data:image\"))return null;e=[...n.matchAll(/url\\(\\s*?['\"]?\\s*?(.+?)\\s*?[\"']?\\s*?\\)/gi)];i.bg_set=e.map(e=>e[1]?{src:e[1].trim()+(e[2]?\" \"+e[2].trim():\"\")}:{}),i.bg_set.every(e=>\"\"===e.src)&&(i.bg_set=e.map(e=>e[1]?{src:e[1].trim()}:{})),0null!==e.elementInfo);e?this.performanceImages=[{...e.elementInfo,label:\"lcp\"}]:(this._logMessage(\"No LCP candidate found.\"),this.performanceImages=[])}_fillATFWithoutDuplications(e){e.forEach(e=>{var{element:e,elementInfo:t}=e;!this._isDuplicateImage(e)&&t&&this.performanceImages.push({...t,label:\"above-the-fold\"})})}_isDuplicateImage(e){let t=this._getElementInfo(e);var i;return null!==t&&(e=\"img\"===t.type||\"img-srcset\"===t.type||\"video\"===t.type,i=\"bg-img\"===t.type||\"bg-img-set\"===t.type||\"picture\"===t.type,e||i)&&this.performanceImages.some(e=>e.src===t.src)}_logMessage(e){this.config.debug&&console.log(e)}getResults(){return this.performanceImages}}n.run()},{}]},{},[1]);"],"file":"wpr-beacon.min.js"} \ No newline at end of file diff --git a/dynamic-lists.json b/dynamic-lists.json index af42cd81ef..a64ab5d891 100644 --- a/dynamic-lists.json +++ b/dynamic-lists.json @@ -1 +1 @@ -{"rucss_inline_atts_exclusions":["rocket-lazyload-inline-css","divi-style-parent-inline-inline-css","gsf-custom-css","extra-style-inline-inline-css","woodmart-inline-css-inline-css","woodmart_shortcodes-custom-css","rs-plugin-settings-inline-css","divi-style-inline-inline-css","tcb-post-list-dynamic-style","n2-ss-","wpcf7-","siteorigin-panels-layouts-footer","xstore-inline-css-inline-css","assets.reviews.io","ezoicCSS","stk-"],"rucss_inline_content_exclusions":[".wp-container-",".wp-elements-","#wpv-expandable-",".custom-content-","#thb-",".et_pb_text_dap_","#gdlr-core-shape-divider","#ultib3-",".uvc-wrap-",".jet-listing-dynamic-post-",".vcex_",".wprm-advanced-list-",".adsslot_",".jnews_",".cp-info-bar.content-","#stockie-custom-","#ohio-custom-",".uid-","#wpfMainWrapper","#penci_","#penci-",".wpbs_s","#apcore_","#apress_","#zolo_",".extended-products-grid#style-",".preloader#style-preloader-",".thegem-heading-",".thegem-button-",".thegem-custom-",".thegem-popup-","#pattern-","#thegem-video-frame-","#thegem-",".qwery_inline_",".dcgd_submit_button",".irs-bar",".gallery-grid-",".cmplz-hidden","#sqbquizouter","#start_sqbquizouter",".flo-header--",".trx_addons_inline_",".wpp-cardview-compact",".e-loop-item-",".tiered-pricing-plain-text",".vc_cta3_content-container"],"defer_js_inline_exclusions":["DOMContentLoaded","document.write","window.lazyLoadOptions","N.N2_","rev_slider_wrapper","FB3D_CLIENT_LOCALE","ewww_webp_supported","anr_captcha_field_div","renderInvisibleReCaptcha","bookingInProgress"],"defer_js_external_exclusions":["gist.github.com","content.jwplatform.com","js.hsforms.net","www.uplaunch.com","google.com\/recaptcha","widget.reviews.co.uk","verify.authorize.net\/anetseal","lib\/admin\/assets\/lib\/webfont\/webfont.min.js","app.mailerlite.com","widget.reviews.io","simplybook.(.*)\/v2\/widget\/widget.js","\/wp-includes\/js\/dist\/i18n.min.js","\/wp-content\/plugins\/wpfront-notification-bar\/js\/wpfront-notification-bar(.*).js","\/wp-content\/plugins\/oxygen\/component-framework\/vendor\/aos\/aos.js","\/wp-content\/plugins\/ewww-image-optimizer\/includes\/check-webp(.min)?.js","static.mailerlite.com\/data\/(.*).js","cdn.voxpow.com\/static\/libs\/v1\/(.*).js","cdn.voxpow.com\/media\/trackers\/js\/(.*).js","use.typekit.net","www.idxhome.com","\/wp-includes\/js\/dist\/vendor\/lodash(.min)?.js","\/wp-includes\/js\/dist\/api-fetch(.min)?.js","\/wp-includes\/js\/dist\/i18n(.min)?.js","\/wp-includes\/js\/dist\/vendor\/wp-polyfill(.min)?.js","\/wp-includes\/js\/dist\/url(.min)?.js","\/wp-includes\/js\/dist\/hooks(.min)?.js","www.paypal.com\/sdk\/js","js-eu1.hsforms.net","yanovis.Voucher.js","\/carousel-upsells-and-related-product-for-woocommerce\/assets\/js\/glide.min.js","use.typekit.com","\/artale\/modules\/kirki\/assets\/webfont.js","\/api\/scripts\/lb_cs.js","js.hscta.net\/cta\/current.js","widget.refari.co","player.vdocipher.com","\/wp-content\/plugins\/wp-rocket\/assets\/js\/lcp-beacon(.min)?.js"],"delay_js_exclusions":["nowprocket","\/wp-includes\/js\/wp-embed.min.js","lazyLoadOptions","lazyLoadThumb","wp-rocket\/assets\/js\/lazyload\/(.*)","et_core_page_resource_fallback","window.\\$us === undefined","js-extra","fusionNavIsCollapsed","\/assets\/js\/smush-lazy-load","eio_lazy_vars","\\\/lazysizes(\\.min|-pre|-post)?\\.js","document\\.body\\.classList\\.remove\\(\"no-js\"\\)","document\\.documentElement\\.className\\.replace\\( 'no-js', 'js' \\)","et_animation_data","wpforms_settings","var nfForms","\/\/stats.wp.com","_stq.push","fluent_form_ff_form_instance_","cpLoadCSS","ninja_column_","var rbs_gallery_","var lepopup_","var billing_additional_field","var gtm4wp","var dataLayer_content","\/ewww-image-optimizer\/includes\/load[_-]webp(\\.min)?.js","\/ewww-image-optimizer\/includes\/check-webp(\\.min)?.js","ewww_webp_supported","\/dist\/js\/browser-redirect\/app.js","\/perfmatters\/js\/lazyload.min.js","lazyLoadInstance","scripts.mediavine.com\/tags\/","initCubePortfolio","simpli.fi","gforms_recaptcha_","\/jetpack-boost\/vendor\/automattic\/jetpack-lazy-images\/(.*)","jetpack-lazy-images-js-enabled","jetpack-boost-critical-css","wpformsRecaptchaCallback","booking-suedtirol-js","wpcp_css_disable_selection","\/gravityforms\/js\/conditional_logic.min.js","statcounter.com\/counter\/counter.js","var sc_project","\/jetpack\/jetpack_vendor\/automattic\/jetpack-lazy-images\/(.*)","\/themify-builder\/themify\/js\/modules\/fallback(\\.min)?.js","handlePixMessage","var corner_video","cdn.pixfuture.com\/hb_v2.js","cdn.pixfuture.com\/pbix.js","served-by.pixfuture.com\/www\/delivery\/ads.js","served-by.pixfuture.com\/www\/delivery\/headerbid_sticky_refresh.js","serv-vdo.pixfuture.com\/vpaid\/ads.js","wprRemoveCPCSS","window.jdgmSettings","\/photonic\/include\/js\/front-end\/nomodule\/photonic-baguettebox.min.js","\/photonic\/include\/ext\/baguettebox\/baguettebox.min.js","window.wsf_form_json_config","et_link_options_data","FuseboxPlayerAPIKey","js.hscta.net\/cta\/current.js","hbspt.cta.load","consent.cookiebot.com\/uc.js","\/woofilter-pro\/woofilterpro\/js\/ion.rangeSlider.min.js","barra.r7.com\/barra.js","rocket_css_lazyload_launch","#wpr-lazyload-bg","\/wp-content\/plugins\/wp-rocket\/assets\/js\/lcp-beacon(.min)?.js","rocket_lcp_data"],"js_minify_external":["html5.js","show_ads.js","histats.com\/js","ws.amazon.com\/widgets","\/ads\/","intensedebate.com","scripts.chitika.net\/","jotform.com\/","gist.github.com","forms.aweber.com","video.unrulymedia.com","stats.wp.com","stats.wordpress.com","widget.rafflecopter.com","widget-prime.rafflecopter.com","releases.flowplayer.org","c.ad6media.fr","cdn.stickyadstv.com","www.smava.de","contextual.media.net","app.getresponse.com","adserver.reklamstore.com","s0.wp.com","wprp.zemanta.com","files.bannersnack.com","smarticon.geotrust.com","js.gleam.io","ir-na.amazon-adsystem.com","web.ventunotech.com","verify.authorize.net","ads.themoneytizer.com","embed.finanzcheck.de","imagesrv.adition.com","js.juicyads.com","form.jotformeu.com","speakerdeck.com","content.jwplatform.com","ads.investingchannel.com","app.ecwid.com","www.industriejobs.de","s.gravatar.com","googlesyndication.com","a.optmstr.com","a.optmnstr.com","a.opmnstr.com","adthrive.com","mediavine.com","js.hsforms.net","googleadservices.com","f.convertkit.com","recaptcha\/api.js","mailmunch.co","apps.shareaholic.com","dsms0mj1bbhn4.cloudfront.net","nutrifox.com","code.tidio.co","www.uplaunch.com","widget.reviewability.com","embed-cdn.gettyimages.com\/widgets.js","app.mailerlite.com","ck.page","cdn.jsdelivr.net\/gh\/AmauriC\/","static.klaviyo.com\/onsite\/js\/klaviyo.js","a.omappapi.com\/app\/js\/api.min.js","static.zdassets.com","feedbackcompany.com\/widgets\/feedback-company-widget.min.js","widget.gleamjs.io","phonewagon.com","simplybook.asia\/v2\/widget\/widget.js","simplybook.it\/v2\/widget\/widget.js","simplybook.me\/v2\/widget\/widget.js","static.botsrv.com\/website\/js\/widget2.36cf1446.js","static.mailerlite.com\/data\/","cdn.voxpow.com","loader.knack.com","embed.lpcontent.net\/leadboxes\/current\/embed.js","cc.cdn.civiccomputing.com\/9\/cookieControl-9.x.min.js","cse.google.com\/cse.js","kit.fontawesome.com","cdn.jsdelivr.net\/npm\/mathjax@3\/es5\/tex-mml-chtml.js","static.leadpages.net\/leadbars\/current\/embed.js","booqable.com\/v2\/booqable.js","googleoptimize.com","cdna.hubpeople.com\/js\/widget_standalone_two_modes.js","s3.tradingview.com","www.vbt.io\/ext\/vbtforms.js","cdn.callrail.com","documentcloud.adobe.com\/view-sdk\/main.js","static.cleverpush.com","js.afterpay.com","cdn.enable.co.il\/licenses\/enable-","hcaptcha.com\/1\/api.js","voucher.getavo.it\/public\/js\/yanovis.Voucher.js","js-eu1.hsforms.net","statcounter.com\/counter\/counter.js","snapppt.com","use.typekit.com","secure.gravatar.com\/js\/gprofiles.js","cdn.jsdelivr.net\/npm\/hockeystack","widget.prod.faslet.net","ga.getresponse.com\/script\/ga.js","cognitoforms.com","usercentrics.eu","cdn.amcharts.com","umami","cdn.popt.in\/pixel.js","m2d.m2.ai","pubguru.net","trustindex.io","cdnjs.cloudflare.com\/ajax\/libs\/prism\/","podigee-podcast-player.js","tarteaucitron.io\/load.js","osm.klarnaservices.com\/lib.js","mein.clickskeks.at\/app.js","barra.r7.com\/barra.js","widget.refari.co","widget.reviews.co.uk","player.vdocipher.com","www.instagram.com\/embed.js","smartframe.io","challenges.cloudflare.com\/turnstile\/","script.roboassist.ai","cdn.hu-manity.co","daumcdn.net\/mapjsapi\/bundle\/postcode\/prod\/postcode.v2.js","consent.cookiebot.com\/uc.js"],"js_move_after_combine":["map_fusion_map_","ec:addProduct","ec:addImpression","clear_better_facebook_comments","vc-row-destroy-equal-heights-","dfd-icon-list-","SFM_template","WLTChangeState","wlt_star_","wlt_pop_distance_","smart_list_tip","gd-wgt-pagi-","data-rf-id=","tvc_po=","scrapeazon","startclock","it_logo_field_owl-box_","td_live_css_uid","wpvl_paramReplace","tdAjaxCount","mec_skin_","_wca","_taboola","fbq('trackCustom'","fbq('track'","data.token","sharrre","dfads_ajax_load_ads","tie_postviews","wmp_update","h5ab-print-article","gform_ajax_frame_","gform_post_render","mts_view_count","act_css_tooltip","window.SLB","wpt_view_count","var dateNow","gallery_product_",".flo-block-slideshow-","data='api-key=ct-","ip_common_function()","(\"style#gsf-custom-css\").append","a3revWCDynamicGallery_","#owl-carousel-instagram-","window.FlowFlowOpts","jQuery('.td_uid_","jQuery(\".slider-","#dfd-vcard-widget-","#sf-instagram-widget-",".woocommerce-tabs-","penci_megamenu__","vc_prepareHoverBox","wp-temp-form-div","_wswebinarsystem_already_","#views-extra-css\").text","fusetag.setTargeting","hit.uptrendsdata.com","callback:window.renderBadge","test_run_nf_conditional_logic","cb_nombre","$('.fl-node-","function($){google_maps_","$(\"#myCarousel","et_animation_data=","current_url=\"","CustomEvent.prototype=window.Event.prototype","electro-wc-product-gallery","woof_is_mobile","jQuery('.videonextup","wpp_params","us.templateDirectoryUri=",".fat-gallery-item",".ratingbox","user_rating.prototype.eraseCookie","test_run_nf_conditional","dpsp-networks-btns-wrapper","pa_woo_product_info","sharing_enabled_on_post_via_metabox","#product-search-field-","GOTMLS_login_offset","berocket_aapf_time_to_fix_products_style","window.vc_googleMapsPointer","sinceID_","#ut-background-video-ut-section","+window.comment_tab_width+","dfd-button-hover-in","wpseo-address-wrapper","platform.stumbleupon.com","#woo_pp_ec_button_mini_cart","#supercarousel","blockClass","tdbMenuItem","tdbSearchItem","best_seller_badge","jQuery('#product-top-bar","fb_desc-","FC_regenerate_captcha","wp_post_blocks_vars.listed_posts=[","captcha-hash","mapdata={",".ywpc-char-",").countdowntimer(","jQuery(\"#td_uid_","find('#td_uid_","variation_estimate_msg"],"js_excluded_inline":["document.write","google_ad","edToolbar","gtag","_gaq.push","_gaLt","GoogleAnalyticsObject","syntaxhighlighter","adsbygoogle","ci_cap_","_stq","nonce","post_id","LogHuman","idcomments_acct","ch_client","sc_online_t","_stq","bannersnack_embed","vtn_player_type","ven_video_key","ANS_customer_id","tdBlock","tdLocalCache","wpRestNonce","\"url\":","lazyLoadOptions","adthrive","loadCSS","google_tag_params","clicky_custom","clicky_site_ids","NSLPopupCenter","_paq","gtm","dataLayer","RecaptchaLoad","WPCOM_sharing_counts","jetpack_remote_comment","subscribe-field","contextly","_mmunch","gt_request_uri","doGTranslate","docTitle","bs_ajax_paginate_","bs_deferred_loading_","theChampRedirectionUrl","theChampFBCommentUrl","theChampTwitterRedirect","theChampRegRedirectionUrl","ESSB_CACHE_URL","oneall_social_login_providers_","betterads_screen_width","woocommerce_wishlist_add_to_wishlist_url","arf_conditional_logic","heateorSsHorSharingShortUrl","TL_Const","bimber_front_microshare","setAttribute(\"id\"","setAttribute( \"id\"","TribeEventsPro","peepsotimedata","wphc_data","hc_rand_id","RBL_ADD","AfsAnalyticsObject","_thriveCurrentPost","esc_login_url","fwduvpMainPlaylist","Bibblio.initRelatedContent","showUFC()","#iphorm-","#fancy-","ult-carousel-","theChampLJAuthUrl","f._fbq","Insticator","w2dc_js_objects","cherry_ajax","ad_block_","elementorFrontendConfig","zeen_","disqusIdentifier","currentAjaxUrl","geodir_event_call_calendar_","atatags-","hbspt.forms.create","function(c,h,i,m,p)","dataTable({","rankMath = {","_atrk_opts","quicklinkOptions","ct_checkjs_","WP_Statistics_http","penci_block_","omapi_localized","omapi_data","OptinMonsterApp","tminusnow","nfForms","galleries.gallery_","wcj_evt.prodID","advads_tracking_ads","advadsGATracking.postContext","woopack_config","ulp_content_id","wp-cumulus\/tagcloud.swf?r=","ctSetCookie('ct_checkjs'","woof_really_curr_tax","uLogin.customInit","i18n_no_matching_variations_text","alsp_map_markers_attrs","var inc_opt =","iworks_upprev","yith_wcevti_tickets","window.metrilo.ensure_cbuid","metrilo.event","wordpress_page_root","wcct_info","Springbot.product_id","pysWooProductData","dfd-heading","owl=$(\"#","penci_megamenu","fts_security","algoliaAutocomplete","avia_framework_globals","tabs.easyResponsiveTabs","searchlocationHeader","yithautocomplete","data-parallax-speed","currency_data=","cedexisData","function reenableButton","#wpnbio-show","e.Newsletter2GoTrackingObject","var categories_","\"+nRemaining+\"","cartsguru_cart_token","after_share_easyoptin","location_data.push","thirstyFunctions.isThirstyLink","styles: ' #custom-menu-","function svc_center_","#svc_carousel2_container_","advads.move","elementid","advads_has_ads","wpseo_map_init","mdf_current_page_url","tptn_tracker","dpsp_pin_button_data","searchwp_live_search_params","wpp_params","top.location,thispage","selection+pagelink","ic_window_resolution","PHP.wp_p_id","ShopifyBuy.UI.onReady(client)","orig_request_uri","gie.widgets.load","Adman.Flash","PHP.wp_p_id","window.broadstreetKeywords","var productId =","var flatsomeVars","wc_product_block_data","static.mailerlite.com","amzn_assoc","_bs_getParameterByName","_stq.push","h._remove","var FlowFlowOpts","var WCPFData =","var _beeketing","var _statcounter","var actions =","var current_url","var object_name","var the_ajax_script","var wc_cart_fragments_params","var woocommerce_params","var wpml_cookies","wc_add_to_cart_params","window.broadstreetKeywords","window.wc_ga_pro.available_gateways","xa.prototype","HOUZEZ_ajaxcalls_vars","w2dc_maps_objects","w2dc_controller_args_array","w2dc_map_markers_attrs","YT.Player","WPFC.data","function current_video_","var videodiv","var slider_wppasrotate","wppas_ga","var blockClass","tarteaucitron","pw_brand_product_list","tminusCountDown","pysWooSelectContentData","wpvq_ans89733","_isp_version","price_range_data","window.FeedbackCompanyWidgets","woocs_current_currency","woo_variation_swatches_options","woocommerce_price_slider_params","scriptParams","form-adv-pagination","borlabsCookiePrioritize","urls_wpwidgetpolylang","quickViewNonce","frontendscripts_params","nj-facebook-messenger","var fb_mess_position","init_particles_row_background_script","setREVStartSize","fl-node","PPAccordion","soliloquy_","wprevpublicjs_script_vars","DTGS_NONCE_FRONTEND","et_animation_data","archives-dropdown","loftloaderCache","SmartSliderSimple","var nectarLove","var incOpt","RocketBrowserCompatibilityChecker","RocketPreloadLinksConfig","placementVersionId","var useEdit","var DTGS_NONCE_FRONTEND","n2jQuery","et_core_api_spam_recaptcha","cnArgs","__CF$cv$params","trustbox_settings","aepro","cdn.jst.ai","w2dc_fields_in_categories","jetMenuPublicSettings","JetTricksSettings","aepc_pixel","avadaWooCommerceVars","var isb","fcaPcPost","csrf_token","icwp_wpsf_vars_lpantibot","wpvViewHead","ed_school_plugin","aps_comp_","guaven_woos","__lm_redirect_to","__wpdm_view_count","bookacti.booking_system","nfFrontEnd","view_quote_cart_link","__eae_decode_emails","divioverlays_ajaxurl","var _EPYT_","#ins-heading-","#ins-button-","tve_frontend_options","lb24.src","amazon_Login_accessToken","porto_infinite_scroll",".adace-loader-","adace_load_","tagGroupsAccordiontaggroupscloudaccordion","tagGroupsTabstaggroupscloudtabs","jrRelatedWidgets","UNCODE.initRow","amp_mobile_redirect_disabled","wpgdprcData","wpml_browser_redirect_params","swPreRegister","kboard_settings","ct_ultimate_gdpr_cookie","wcpv_registration_local","www.idxhome.com","arf_footer_cl_logic_call","reload_attached_coupons","var ftpp","forminatorFront","_EPYT_","edd_free_downloads_vars","edd_stripe_vars","var ASP","ecwidOriginalTitle","defaultCategoryId","translation-revision-date","google_conversion_id","hbspt","var marker_locations_","var AdmMyAjax","ifso_page_url","referrer_for_pageload","WoocommerceWidget\/woocommerceWidget.js","var ht_ctc_chat_var","spuvar","var wpilFrontend","urls_polylangREPLACETOID","e.setAttribute('unselectable',on);","try{Typekit.load","iMapsData","var wpforms_user_journey","rocket_lazyload_css_data","wcStoreApiNonceTimestamp","createNonceMiddleware","pbidHash","wcBlocksMiddlewareConfig"],"cache_ignored_parameters":["utm_source","utm_medium","utm_campaign","utm_expid","utm_term","utm_content","utm_id","utm_source_platform","utm_creative_format","utm_marketing_tactic","mtm_source","mtm_medium","mtm_campaign","mtm_keyword","mtm_cid","mtm_content","pk_source","pk_medium","pk_campaign","pk_keyword","pk_cid","pk_content","fb_action_ids","fb_action_types","fb_source","fbclid","campaignid","adgroupid","adid","gclid","age-verified","ao_noptimize","usqp","cn-reloaded","_ga","sscid","gclsrc","_gl","mc_cid","mc_eid","_bta_tid","_bta_c","trk_contact","trk_msg","trk_module","trk_sid","gdfms","gdftrk","gdffi","_ke","_kx","redirect_log_mongo_id","redirect_mongo_id","sb_referer_host","mkwid","pcrid","ef_id","s_kwcid","msclkid","dm_i","epik","pp","gbraid","wbraid","ssp_iabi","ssp_iaba","gad","vgo_ee","gad_source"],"preload_exclusions":["void\\(.*;","(.*)__trashed(.*)","\/jet-menu\/(.*)","\/jet-popup\/(.*)"],"exclude_js_files":["\/wp-includes\/js\/dist\/i18n.min.js","\/interactive-3d-flipbook-powered-physics-engine\/assets\/js\/html2canvas.min.js","\/interactive-3d-flipbook-powered-physics-engine\/assets\/js\/pdf.min.js","\/interactive-3d-flipbook-powered-physics-engine\/assets\/js\/three.min.js","\/interactive-3d-flipbook-powered-physics-engine\/assets\/js\/3d-flip-book.min.js","\/google-site-kit\/dist\/assets\/js\/(.*).js","\/wp-live-chat-support\/public\/js\/callus(.*).js","\/borlabs-cookie\/assets\/javascript\/(.*).js","\/wp-content\/plugins\/wp-rocket\/assets\/js\/lcp-beacon(.min)?.js","\/woocommerce-bookings\/dist\/frontend.js","\/plugins\/mapify(.*)\/assets\/js\/dist\/bundle.js"],"staging_domains":[".wpengine.com",".wpenginepowered.com",".pantheonsite.io",".flywheelsites.com",".flywheelstaging.com",".kinsta.com",".kinsta.cloud",".cloudwaysapps.com",".azurewebsites.net",".wpserveur.net","-liquidwebsites.com",".myftpupload.com",".dream.press",".sg-host.com",".platformsh.site",".wpstage.net",".bigscoots-staging.com",".wpsc.site",".runcloud.link",".onrocket.site",".singlestaging.com",".myraidbox.de",".instawp.xyz",".instawp.co",".instawp.link",".instawp.app",".hstgr.cloud",".myhostpoint.ch",".wpcomstaging.com"],"exclude_js_template":["type=\"module\""]} \ No newline at end of file +{"rucss_inline_atts_exclusions":["rocket-lazyload-inline-css","divi-style-parent-inline-inline-css","gsf-custom-css","extra-style-inline-inline-css","woodmart-inline-css-inline-css","woodmart_shortcodes-custom-css","rs-plugin-settings-inline-css","divi-style-inline-inline-css","tcb-post-list-dynamic-style","n2-ss-","wpcf7-","siteorigin-panels-layouts-footer","xstore-inline-css-inline-css","assets.reviews.io","ezoicCSS","stk-"],"rucss_inline_content_exclusions":[".wp-container-",".wp-elements-","#wpv-expandable-",".custom-content-","#thb-",".et_pb_text_dap_","#gdlr-core-shape-divider","#ultib3-",".uvc-wrap-",".jet-listing-dynamic-post-",".vcex_",".wprm-advanced-list-",".adsslot_",".jnews_",".cp-info-bar.content-","#stockie-custom-","#ohio-custom-",".uid-","#wpfMainWrapper","#penci_","#penci-",".wpbs_s","#apcore_","#apress_","#zolo_",".extended-products-grid#style-",".preloader#style-preloader-",".thegem-heading-",".thegem-button-",".thegem-custom-",".thegem-popup-","#pattern-","#thegem-video-frame-","#thegem-",".qwery_inline_",".dcgd_submit_button",".irs-bar",".gallery-grid-",".cmplz-hidden","#sqbquizouter","#start_sqbquizouter",".flo-header--",".trx_addons_inline_",".wpp-cardview-compact",".e-loop-item-",".tiered-pricing-plain-text",".vc_cta3_content-container"],"defer_js_inline_exclusions":["DOMContentLoaded","document.write","window.lazyLoadOptions","N.N2_","rev_slider_wrapper","FB3D_CLIENT_LOCALE","ewww_webp_supported","anr_captcha_field_div","renderInvisibleReCaptcha","bookingInProgress"],"defer_js_external_exclusions":["gist.github.com","content.jwplatform.com","js.hsforms.net","www.uplaunch.com","google.com\/recaptcha","widget.reviews.co.uk","verify.authorize.net\/anetseal","lib\/admin\/assets\/lib\/webfont\/webfont.min.js","app.mailerlite.com","widget.reviews.io","simplybook.(.*)\/v2\/widget\/widget.js","\/wp-includes\/js\/dist\/i18n.min.js","\/wp-content\/plugins\/wpfront-notification-bar\/js\/wpfront-notification-bar(.*).js","\/wp-content\/plugins\/oxygen\/component-framework\/vendor\/aos\/aos.js","\/wp-content\/plugins\/ewww-image-optimizer\/includes\/check-webp(.min)?.js","static.mailerlite.com\/data\/(.*).js","cdn.voxpow.com\/static\/libs\/v1\/(.*).js","cdn.voxpow.com\/media\/trackers\/js\/(.*).js","use.typekit.net","www.idxhome.com","\/wp-includes\/js\/dist\/vendor\/lodash(.min)?.js","\/wp-includes\/js\/dist\/api-fetch(.min)?.js","\/wp-includes\/js\/dist\/i18n(.min)?.js","\/wp-includes\/js\/dist\/vendor\/wp-polyfill(.min)?.js","\/wp-includes\/js\/dist\/url(.min)?.js","\/wp-includes\/js\/dist\/hooks(.min)?.js","www.paypal.com\/sdk\/js","js-eu1.hsforms.net","yanovis.Voucher.js","\/carousel-upsells-and-related-product-for-woocommerce\/assets\/js\/glide.min.js","use.typekit.com","\/artale\/modules\/kirki\/assets\/webfont.js","\/api\/scripts\/lb_cs.js","js.hscta.net\/cta\/current.js","widget.refari.co","player.vdocipher.com","\/wp-content\/plugins\/wp-rocket\/assets\/js\/wpr-beacon(.min)?.js"],"delay_js_exclusions":["nowprocket","\/wp-includes\/js\/wp-embed.min.js","lazyLoadOptions","lazyLoadThumb","wp-rocket\/assets\/js\/lazyload\/(.*)","et_core_page_resource_fallback","window.\\$us === undefined","js-extra","fusionNavIsCollapsed","\/assets\/js\/smush-lazy-load","eio_lazy_vars","\\\/lazysizes(\\.min|-pre|-post)?\\.js","document\\.body\\.classList\\.remove\\(\"no-js\"\\)","document\\.documentElement\\.className\\.replace\\( 'no-js', 'js' \\)","et_animation_data","wpforms_settings","var nfForms","\/\/stats.wp.com","_stq.push","fluent_form_ff_form_instance_","cpLoadCSS","ninja_column_","var rbs_gallery_","var lepopup_","var billing_additional_field","var gtm4wp","var dataLayer_content","\/ewww-image-optimizer\/includes\/load[_-]webp(\\.min)?.js","\/ewww-image-optimizer\/includes\/check-webp(\\.min)?.js","ewww_webp_supported","\/dist\/js\/browser-redirect\/app.js","\/perfmatters\/js\/lazyload.min.js","lazyLoadInstance","scripts.mediavine.com\/tags\/","initCubePortfolio","simpli.fi","gforms_recaptcha_","\/jetpack-boost\/vendor\/automattic\/jetpack-lazy-images\/(.*)","jetpack-lazy-images-js-enabled","jetpack-boost-critical-css","wpformsRecaptchaCallback","booking-suedtirol-js","wpcp_css_disable_selection","\/gravityforms\/js\/conditional_logic.min.js","statcounter.com\/counter\/counter.js","var sc_project","\/jetpack\/jetpack_vendor\/automattic\/jetpack-lazy-images\/(.*)","\/themify-builder\/themify\/js\/modules\/fallback(\\.min)?.js","handlePixMessage","var corner_video","cdn.pixfuture.com\/hb_v2.js","cdn.pixfuture.com\/pbix.js","served-by.pixfuture.com\/www\/delivery\/ads.js","served-by.pixfuture.com\/www\/delivery\/headerbid_sticky_refresh.js","serv-vdo.pixfuture.com\/vpaid\/ads.js","wprRemoveCPCSS","window.jdgmSettings","\/photonic\/include\/js\/front-end\/nomodule\/photonic-baguettebox.min.js","\/photonic\/include\/ext\/baguettebox\/baguettebox.min.js","window.wsf_form_json_config","et_link_options_data","FuseboxPlayerAPIKey","js.hscta.net\/cta\/current.js","hbspt.cta.load","consent.cookiebot.com\/uc.js","\/woofilter-pro\/woofilterpro\/js\/ion.rangeSlider.min.js","barra.r7.com\/barra.js","rocket_css_lazyload_launch","#wpr-lazyload-bg","\/wp-content\/plugins\/wp-rocket\/assets\/js\/wpr-beacon(.min)?.js","rocket_lcp_data"],"js_minify_external":["html5.js","show_ads.js","histats.com\/js","ws.amazon.com\/widgets","\/ads\/","intensedebate.com","scripts.chitika.net\/","jotform.com\/","gist.github.com","forms.aweber.com","video.unrulymedia.com","stats.wp.com","stats.wordpress.com","widget.rafflecopter.com","widget-prime.rafflecopter.com","releases.flowplayer.org","c.ad6media.fr","cdn.stickyadstv.com","www.smava.de","contextual.media.net","app.getresponse.com","adserver.reklamstore.com","s0.wp.com","wprp.zemanta.com","files.bannersnack.com","smarticon.geotrust.com","js.gleam.io","ir-na.amazon-adsystem.com","web.ventunotech.com","verify.authorize.net","ads.themoneytizer.com","embed.finanzcheck.de","imagesrv.adition.com","js.juicyads.com","form.jotformeu.com","speakerdeck.com","content.jwplatform.com","ads.investingchannel.com","app.ecwid.com","www.industriejobs.de","s.gravatar.com","googlesyndication.com","a.optmstr.com","a.optmnstr.com","a.opmnstr.com","adthrive.com","mediavine.com","js.hsforms.net","googleadservices.com","f.convertkit.com","recaptcha\/api.js","mailmunch.co","apps.shareaholic.com","dsms0mj1bbhn4.cloudfront.net","nutrifox.com","code.tidio.co","www.uplaunch.com","widget.reviewability.com","embed-cdn.gettyimages.com\/widgets.js","app.mailerlite.com","ck.page","cdn.jsdelivr.net\/gh\/AmauriC\/","static.klaviyo.com\/onsite\/js\/klaviyo.js","a.omappapi.com\/app\/js\/api.min.js","static.zdassets.com","feedbackcompany.com\/widgets\/feedback-company-widget.min.js","widget.gleamjs.io","phonewagon.com","simplybook.asia\/v2\/widget\/widget.js","simplybook.it\/v2\/widget\/widget.js","simplybook.me\/v2\/widget\/widget.js","static.botsrv.com\/website\/js\/widget2.36cf1446.js","static.mailerlite.com\/data\/","cdn.voxpow.com","loader.knack.com","embed.lpcontent.net\/leadboxes\/current\/embed.js","cc.cdn.civiccomputing.com\/9\/cookieControl-9.x.min.js","cse.google.com\/cse.js","kit.fontawesome.com","cdn.jsdelivr.net\/npm\/mathjax@3\/es5\/tex-mml-chtml.js","static.leadpages.net\/leadbars\/current\/embed.js","booqable.com\/v2\/booqable.js","googleoptimize.com","cdna.hubpeople.com\/js\/widget_standalone_two_modes.js","s3.tradingview.com","www.vbt.io\/ext\/vbtforms.js","cdn.callrail.com","documentcloud.adobe.com\/view-sdk\/main.js","static.cleverpush.com","js.afterpay.com","cdn.enable.co.il\/licenses\/enable-","hcaptcha.com\/1\/api.js","voucher.getavo.it\/public\/js\/yanovis.Voucher.js","js-eu1.hsforms.net","statcounter.com\/counter\/counter.js","snapppt.com","use.typekit.com","secure.gravatar.com\/js\/gprofiles.js","cdn.jsdelivr.net\/npm\/hockeystack","widget.prod.faslet.net","ga.getresponse.com\/script\/ga.js","cognitoforms.com","usercentrics.eu","cdn.amcharts.com","umami","cdn.popt.in\/pixel.js","m2d.m2.ai","pubguru.net","trustindex.io","cdnjs.cloudflare.com\/ajax\/libs\/prism\/","podigee-podcast-player.js","tarteaucitron.io\/load.js","osm.klarnaservices.com\/lib.js","mein.clickskeks.at\/app.js","barra.r7.com\/barra.js","widget.refari.co","widget.reviews.co.uk","player.vdocipher.com","www.instagram.com\/embed.js","smartframe.io","challenges.cloudflare.com\/turnstile\/","script.roboassist.ai","cdn.hu-manity.co","daumcdn.net\/mapjsapi\/bundle\/postcode\/prod\/postcode.v2.js","consent.cookiebot.com\/uc.js"],"js_move_after_combine":["map_fusion_map_","ec:addProduct","ec:addImpression","clear_better_facebook_comments","vc-row-destroy-equal-heights-","dfd-icon-list-","SFM_template","WLTChangeState","wlt_star_","wlt_pop_distance_","smart_list_tip","gd-wgt-pagi-","data-rf-id=","tvc_po=","scrapeazon","startclock","it_logo_field_owl-box_","td_live_css_uid","wpvl_paramReplace","tdAjaxCount","mec_skin_","_wca","_taboola","fbq('trackCustom'","fbq('track'","data.token","sharrre","dfads_ajax_load_ads","tie_postviews","wmp_update","h5ab-print-article","gform_ajax_frame_","gform_post_render","mts_view_count","act_css_tooltip","window.SLB","wpt_view_count","var dateNow","gallery_product_",".flo-block-slideshow-","data='api-key=ct-","ip_common_function()","(\"style#gsf-custom-css\").append","a3revWCDynamicGallery_","#owl-carousel-instagram-","window.FlowFlowOpts","jQuery('.td_uid_","jQuery(\".slider-","#dfd-vcard-widget-","#sf-instagram-widget-",".woocommerce-tabs-","penci_megamenu__","vc_prepareHoverBox","wp-temp-form-div","_wswebinarsystem_already_","#views-extra-css\").text","fusetag.setTargeting","hit.uptrendsdata.com","callback:window.renderBadge","test_run_nf_conditional_logic","cb_nombre","$('.fl-node-","function($){google_maps_","$(\"#myCarousel","et_animation_data=","current_url=\"","CustomEvent.prototype=window.Event.prototype","electro-wc-product-gallery","woof_is_mobile","jQuery('.videonextup","wpp_params","us.templateDirectoryUri=",".fat-gallery-item",".ratingbox","user_rating.prototype.eraseCookie","test_run_nf_conditional","dpsp-networks-btns-wrapper","pa_woo_product_info","sharing_enabled_on_post_via_metabox","#product-search-field-","GOTMLS_login_offset","berocket_aapf_time_to_fix_products_style","window.vc_googleMapsPointer","sinceID_","#ut-background-video-ut-section","+window.comment_tab_width+","dfd-button-hover-in","wpseo-address-wrapper","platform.stumbleupon.com","#woo_pp_ec_button_mini_cart","#supercarousel","blockClass","tdbMenuItem","tdbSearchItem","best_seller_badge","jQuery('#product-top-bar","fb_desc-","FC_regenerate_captcha","wp_post_blocks_vars.listed_posts=[","captcha-hash","mapdata={",".ywpc-char-",").countdowntimer(","jQuery(\"#td_uid_","find('#td_uid_","variation_estimate_msg"],"js_excluded_inline":["document.write","google_ad","edToolbar","gtag","_gaq.push","_gaLt","GoogleAnalyticsObject","syntaxhighlighter","adsbygoogle","ci_cap_","_stq","nonce","post_id","LogHuman","idcomments_acct","ch_client","sc_online_t","_stq","bannersnack_embed","vtn_player_type","ven_video_key","ANS_customer_id","tdBlock","tdLocalCache","wpRestNonce","\"url\":","lazyLoadOptions","adthrive","loadCSS","google_tag_params","clicky_custom","clicky_site_ids","NSLPopupCenter","_paq","gtm","dataLayer","RecaptchaLoad","WPCOM_sharing_counts","jetpack_remote_comment","subscribe-field","contextly","_mmunch","gt_request_uri","doGTranslate","docTitle","bs_ajax_paginate_","bs_deferred_loading_","theChampRedirectionUrl","theChampFBCommentUrl","theChampTwitterRedirect","theChampRegRedirectionUrl","ESSB_CACHE_URL","oneall_social_login_providers_","betterads_screen_width","woocommerce_wishlist_add_to_wishlist_url","arf_conditional_logic","heateorSsHorSharingShortUrl","TL_Const","bimber_front_microshare","setAttribute(\"id\"","setAttribute( \"id\"","TribeEventsPro","peepsotimedata","wphc_data","hc_rand_id","RBL_ADD","AfsAnalyticsObject","_thriveCurrentPost","esc_login_url","fwduvpMainPlaylist","Bibblio.initRelatedContent","showUFC()","#iphorm-","#fancy-","ult-carousel-","theChampLJAuthUrl","f._fbq","Insticator","w2dc_js_objects","cherry_ajax","ad_block_","elementorFrontendConfig","zeen_","disqusIdentifier","currentAjaxUrl","geodir_event_call_calendar_","atatags-","hbspt.forms.create","function(c,h,i,m,p)","dataTable({","rankMath = {","_atrk_opts","quicklinkOptions","ct_checkjs_","WP_Statistics_http","penci_block_","omapi_localized","omapi_data","OptinMonsterApp","tminusnow","nfForms","galleries.gallery_","wcj_evt.prodID","advads_tracking_ads","advadsGATracking.postContext","woopack_config","ulp_content_id","wp-cumulus\/tagcloud.swf?r=","ctSetCookie('ct_checkjs'","woof_really_curr_tax","uLogin.customInit","i18n_no_matching_variations_text","alsp_map_markers_attrs","var inc_opt =","iworks_upprev","yith_wcevti_tickets","window.metrilo.ensure_cbuid","metrilo.event","wordpress_page_root","wcct_info","Springbot.product_id","pysWooProductData","dfd-heading","owl=$(\"#","penci_megamenu","fts_security","algoliaAutocomplete","avia_framework_globals","tabs.easyResponsiveTabs","searchlocationHeader","yithautocomplete","data-parallax-speed","currency_data=","cedexisData","function reenableButton","#wpnbio-show","e.Newsletter2GoTrackingObject","var categories_","\"+nRemaining+\"","cartsguru_cart_token","after_share_easyoptin","location_data.push","thirstyFunctions.isThirstyLink","styles: ' #custom-menu-","function svc_center_","#svc_carousel2_container_","advads.move","elementid","advads_has_ads","wpseo_map_init","mdf_current_page_url","tptn_tracker","dpsp_pin_button_data","searchwp_live_search_params","wpp_params","top.location,thispage","selection+pagelink","ic_window_resolution","PHP.wp_p_id","ShopifyBuy.UI.onReady(client)","orig_request_uri","gie.widgets.load","Adman.Flash","PHP.wp_p_id","window.broadstreetKeywords","var productId =","var flatsomeVars","wc_product_block_data","static.mailerlite.com","amzn_assoc","_bs_getParameterByName","_stq.push","h._remove","var FlowFlowOpts","var WCPFData =","var _beeketing","var _statcounter","var actions =","var current_url","var object_name","var the_ajax_script","var wc_cart_fragments_params","var woocommerce_params","var wpml_cookies","wc_add_to_cart_params","window.broadstreetKeywords","window.wc_ga_pro.available_gateways","xa.prototype","HOUZEZ_ajaxcalls_vars","w2dc_maps_objects","w2dc_controller_args_array","w2dc_map_markers_attrs","YT.Player","WPFC.data","function current_video_","var videodiv","var slider_wppasrotate","wppas_ga","var blockClass","tarteaucitron","pw_brand_product_list","tminusCountDown","pysWooSelectContentData","wpvq_ans89733","_isp_version","price_range_data","window.FeedbackCompanyWidgets","woocs_current_currency","woo_variation_swatches_options","woocommerce_price_slider_params","scriptParams","form-adv-pagination","borlabsCookiePrioritize","urls_wpwidgetpolylang","quickViewNonce","frontendscripts_params","nj-facebook-messenger","var fb_mess_position","init_particles_row_background_script","setREVStartSize","fl-node","PPAccordion","soliloquy_","wprevpublicjs_script_vars","DTGS_NONCE_FRONTEND","et_animation_data","archives-dropdown","loftloaderCache","SmartSliderSimple","var nectarLove","var incOpt","RocketBrowserCompatibilityChecker","RocketPreloadLinksConfig","placementVersionId","var useEdit","var DTGS_NONCE_FRONTEND","n2jQuery","et_core_api_spam_recaptcha","cnArgs","__CF$cv$params","trustbox_settings","aepro","cdn.jst.ai","w2dc_fields_in_categories","jetMenuPublicSettings","JetTricksSettings","aepc_pixel","avadaWooCommerceVars","var isb","fcaPcPost","csrf_token","icwp_wpsf_vars_lpantibot","wpvViewHead","ed_school_plugin","aps_comp_","guaven_woos","__lm_redirect_to","__wpdm_view_count","bookacti.booking_system","nfFrontEnd","view_quote_cart_link","__eae_decode_emails","divioverlays_ajaxurl","var _EPYT_","#ins-heading-","#ins-button-","tve_frontend_options","lb24.src","amazon_Login_accessToken","porto_infinite_scroll",".adace-loader-","adace_load_","tagGroupsAccordiontaggroupscloudaccordion","tagGroupsTabstaggroupscloudtabs","jrRelatedWidgets","UNCODE.initRow","amp_mobile_redirect_disabled","wpgdprcData","wpml_browser_redirect_params","swPreRegister","kboard_settings","ct_ultimate_gdpr_cookie","wcpv_registration_local","www.idxhome.com","arf_footer_cl_logic_call","reload_attached_coupons","var ftpp","forminatorFront","_EPYT_","edd_free_downloads_vars","edd_stripe_vars","var ASP","ecwidOriginalTitle","defaultCategoryId","translation-revision-date","google_conversion_id","hbspt","var marker_locations_","var AdmMyAjax","ifso_page_url","referrer_for_pageload","WoocommerceWidget\/woocommerceWidget.js","var ht_ctc_chat_var","spuvar","var wpilFrontend","urls_polylangREPLACETOID","e.setAttribute('unselectable',on);","try{Typekit.load","iMapsData","var wpforms_user_journey","rocket_lazyload_css_data","wcStoreApiNonceTimestamp","createNonceMiddleware","pbidHash","wcBlocksMiddlewareConfig"],"cache_ignored_parameters":["utm_source","utm_medium","utm_campaign","utm_expid","utm_term","utm_content","utm_id","utm_source_platform","utm_creative_format","utm_marketing_tactic","mtm_source","mtm_medium","mtm_campaign","mtm_keyword","mtm_cid","mtm_content","pk_source","pk_medium","pk_campaign","pk_keyword","pk_cid","pk_content","fb_action_ids","fb_action_types","fb_source","fbclid","campaignid","adgroupid","adid","gclid","age-verified","ao_noptimize","usqp","cn-reloaded","_ga","sscid","gclsrc","_gl","mc_cid","mc_eid","_bta_tid","_bta_c","trk_contact","trk_msg","trk_module","trk_sid","gdfms","gdftrk","gdffi","_ke","_kx","redirect_log_mongo_id","redirect_mongo_id","sb_referer_host","mkwid","pcrid","ef_id","s_kwcid","msclkid","dm_i","epik","pp","gbraid","wbraid","ssp_iabi","ssp_iaba","gad","vgo_ee","gad_source"],"preload_exclusions":["void\\(.*;","(.*)__trashed(.*)","\/jet-menu\/(.*)","\/jet-popup\/(.*)"],"exclude_js_files":["\/wp-includes\/js\/dist\/i18n.min.js","\/interactive-3d-flipbook-powered-physics-engine\/assets\/js\/html2canvas.min.js","\/interactive-3d-flipbook-powered-physics-engine\/assets\/js\/pdf.min.js","\/interactive-3d-flipbook-powered-physics-engine\/assets\/js\/three.min.js","\/interactive-3d-flipbook-powered-physics-engine\/assets\/js\/3d-flip-book.min.js","\/google-site-kit\/dist\/assets\/js\/(.*).js","\/wp-live-chat-support\/public\/js\/callus(.*).js","\/borlabs-cookie\/assets\/javascript\/(.*).js","\/wp-content\/plugins\/wp-rocket\/assets\/js\/lcp-beacon(.min)?.js","\/woocommerce-bookings\/dist\/frontend.js","\/plugins\/mapify(.*)\/assets\/js\/dist\/bundle.js"],"staging_domains":[".wpengine.com",".wpenginepowered.com",".pantheonsite.io",".flywheelsites.com",".flywheelstaging.com",".kinsta.com",".kinsta.cloud",".cloudwaysapps.com",".azurewebsites.net",".wpserveur.net","-liquidwebsites.com",".myftpupload.com",".dream.press",".sg-host.com",".platformsh.site",".wpstage.net",".bigscoots-staging.com",".wpsc.site",".runcloud.link",".onrocket.site",".singlestaging.com",".myraidbox.de",".instawp.xyz",".instawp.co",".instawp.link",".instawp.app",".hstgr.cloud",".myhostpoint.ch",".wpcomstaging.com"],"exclude_js_template":["type=\"module\""]} diff --git a/gulpfile.js b/gulpfile.js index 370fd43aa4..a86e095383 100755 --- a/gulpfile.js +++ b/gulpfile.js @@ -17,8 +17,8 @@ requireDir('./src/js/gulp/tasks', { recurse: true }); * gulp build:js:app:unmin => Builds admin app js file, the unminified version (wpr-admin.js) * gulp build:js:app:min => Builds admin app js file, the minified version (wpr-admin.min.js) * gulp build:js:lazyloadcss:min => Builds lazyload CSS js file, the minified version (lazyload-css.min.js) -* gulp build:js:lcp:min => Builds lcp beacon script, the minified version (lcp-beacon.min.js) -* gulp build:js:all => Builds all js files mentioned above (wpr-admin.js, wpr-admin.min.js, lazyload-css.min.js, lcp-beacon.min.js) +* gulp build:js:lcp:min => Builds wpr beacon script, the minified version (wpr-beacon.min.js) +* gulp build:js:all => Builds all js files mentioned above (wpr-admin.js, wpr-admin.min.js, lazyload-css.min.js, wpr-beacon.min.js) * gulp js:watch => Watches all js files changes and build them again with any change. * */ diff --git a/inc/Engine/Media/AboveTheFold/AJAX/Controller.php b/inc/Engine/Media/AboveTheFold/AJAX/Controller.php index ed5d60526c..8b44147436 100644 --- a/inc/Engine/Media/AboveTheFold/AJAX/Controller.php +++ b/inc/Engine/Media/AboveTheFold/AJAX/Controller.php @@ -59,7 +59,7 @@ public function add_lcp_data() { $url = isset( $_POST['url'] ) ? untrailingslashit( esc_url_raw( wp_unslash( $_POST['url'] ) ) ) : ''; $is_mobile = isset( $_POST['is_mobile'] ) ? filter_var( wp_unslash( $_POST['is_mobile'] ), FILTER_VALIDATE_BOOLEAN ) : false; - $images = isset( $_POST['images'] ) ? json_decode( wp_unslash( $_POST['images'] ) ) : []; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized + $images = isset( $_POST['lcp_images'] ) ? json_decode( wp_unslash( $_POST['lcp_images'] ) ) : []; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized $lcp = 'not found'; $viewport = []; diff --git a/inc/Engine/Media/AboveTheFold/Frontend/Controller.php b/inc/Engine/Media/AboveTheFold/Frontend/Controller.php index 26856608f5..054705a008 100644 --- a/inc/Engine/Media/AboveTheFold/Frontend/Controller.php +++ b/inc/Engine/Media/AboveTheFold/Frontend/Controller.php @@ -369,7 +369,7 @@ private function is_mobile(): bool { public function inject_beacon( $html, $url, $is_mobile ): string { $min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; - if ( ! $this->filesystem->exists( rocket_get_constant( 'WP_ROCKET_ASSETS_JS_PATH' ) . 'lcp-beacon' . $min . '.js' ) ) { + if ( ! $this->filesystem->exists( rocket_get_constant( 'WP_ROCKET_ASSETS_JS_PATH' ) . 'wpr-beacon' . $min . '.js' ) ) { return $html; } @@ -433,10 +433,10 @@ public function inject_beacon( $html, $url, $is_mobile ): string { $inline_script = ''; // Get the URL of the script. - $script_url = rocket_get_constant( 'WP_ROCKET_ASSETS_JS_URL' ) . 'lcp-beacon' . $min . '.js'; + $script_url = rocket_get_constant( 'WP_ROCKET_ASSETS_JS_URL' ) . 'wpr-beacon' . $min . '.js'; // Create the script tag. - $script_tag = ""; // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript + $script_tag = ""; // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript // Append the script tag just before the closing body tag. return str_replace( '', $inline_script . $script_tag . '', $html ); diff --git a/src/js/gulp/tasks/js.js b/src/js/gulp/tasks/js.js index 5b584ce8d6..77ac4b7dfc 100644 --- a/src/js/gulp/tasks/js.js +++ b/src/js/gulp/tasks/js.js @@ -55,7 +55,7 @@ class gulpJs { } buildLcpBeaconMin() { - return this._compile( './assets/js/lcp-beacon.js', 'lcp-beacon', true, true ); + return this._compile( './assets/js/wpr-beacon.js', 'wpr-beacon', true, true ); } buildAll() { @@ -70,7 +70,7 @@ class gulpJs { watch() { gulp.watch('./src/js/global/*.js', gulp.series( 'build:js:app:unmin', 'build:js:app:min' )); gulp.watch( './src/js/custom/lazyload-css.js', gulp.series( 'build:js:lazyloadcss:min' ) ); - gulp.watch( './assets/js/lcp-beacon.js', gulp.series( 'build:js:lcp:min' ) ); + gulp.watch( './assets/js/wpr-beacon.js', gulp.series( 'build:js:lcp:min' ) ); } } diff --git a/tests/Fixtures/inc/Engine/Media/AboveTheFold/AJAX/Controller/addLcpData.php b/tests/Fixtures/inc/Engine/Media/AboveTheFold/AJAX/Controller/addLcpData.php index b3d0eaf2dc..b23debf7e8 100644 --- a/tests/Fixtures/inc/Engine/Media/AboveTheFold/AJAX/Controller/addLcpData.php +++ b/tests/Fixtures/inc/Engine/Media/AboveTheFold/AJAX/Controller/addLcpData.php @@ -31,7 +31,7 @@ 'filter' => false, 'url' => 'http://example.org', 'is_mobile' => false, - 'images' => json_encode( [] ), + 'lcp_images' => json_encode( [] ), ], 'expected' => [ 'images_valid_sources' => [], @@ -52,7 +52,7 @@ 'filter' => true, 'url' => 'http://example.org', 'is_mobile' => false, - 'images' => json_encode( + 'lcp_images' => json_encode( [ (object) [ 'type' => 'img', @@ -112,7 +112,7 @@ 'filter' => true, 'url' => 'http://example.org', 'is_mobile' => false, - 'images' => json_encode( + 'lcp_images' => json_encode( [ (object) [ 'label' => 'lcp', @@ -190,7 +190,7 @@ 'filter' => true, 'url' => 'http://example.org', 'is_mobile' => true, - 'images' => json_encode( + 'lcp_images' => json_encode( [ (object) [ 'label' => 'lcp', @@ -270,7 +270,7 @@ 'filter' => true, 'url' => 'http://example.org', 'is_mobile' => false, - 'images' => json_encode( + 'lcp_images' => json_encode( [ (object) [ 'label' => 'lcp', @@ -351,7 +351,7 @@ 'filter' => true, 'url' => 'http://example.org', 'is_mobile' => false, - 'images' => json_encode( + 'lcp_images' => json_encode( [ (object) [ 'label' => 'lcp', @@ -454,7 +454,7 @@ 'filter' => true, 'url' => 'http://example.org', 'is_mobile' => false, - 'images' => json_encode( + 'lcp_images' => json_encode( [ (object) [ 'label' => 'lcp', @@ -563,7 +563,7 @@ 'filter' => true, 'url' => 'http://example.org', 'is_mobile' => false, - 'images' => json_encode( + 'lcp_images' => json_encode( $long_array ), 'filetype' => [ @@ -610,7 +610,7 @@ 'filter' => true, 'url' => 'http://example.org', 'is_mobile' => false, - 'images' => '', + 'lcp_images' => '', ], 'expected' => [ 'images_valid_sources' => [], @@ -640,7 +640,7 @@ 'filter' => true, 'url' => 'http://example.org', 'is_mobile' => false, - 'images' => json_encode( + 'lcp_images' => json_encode( [ (object) [ 'label' => 'lcp', @@ -685,7 +685,7 @@ 'filter' => true, 'url' => 'http://example.org', 'is_mobile' => false, - 'images' => '', + 'lcp_images' => '', 'status' => 'script_error', ], 'expected' => [ @@ -716,7 +716,7 @@ 'filter' => true, 'url' => 'http://example.org', 'is_mobile' => false, - 'images' => '', + 'lcp_images' => '', 'status' => 'timeout', ], 'expected' => [ @@ -748,7 +748,7 @@ 'filter' => true, 'url' => 'http://example.org', 'is_mobile' => false, - 'images' => json_encode( + 'lcp_images' => json_encode( [ (object) [ 'label' => 'lcp', @@ -800,7 +800,7 @@ 'filter' => true, 'url' => 'http://example.org', 'is_mobile' => false, - 'images' => json_encode( + 'lcp_images' => json_encode( [ (object) [ 'label' => 'lcp', @@ -852,7 +852,7 @@ 'filter' => true, 'url' => 'http://example.org', 'is_mobile' => false, - 'images' => json_encode( + 'lcp_images' => json_encode( [ (object) [ 'label' => 'lcp', @@ -904,7 +904,7 @@ 'filter' => true, 'url' => 'http://example.org', 'is_mobile' => false, - 'images' => json_encode( + 'lcp_images' => json_encode( [ (object) [ 'label' => 'lcp', @@ -956,7 +956,7 @@ 'filter' => true, 'url' => 'http://example.org', 'is_mobile' => false, - 'images' => json_encode( + 'lcp_images' => json_encode( [ (object) [ 'label' => 'lcp', @@ -1008,7 +1008,7 @@ 'filter' => true, 'url' => 'http://example.org', 'is_mobile' => false, - 'images' => json_encode( + 'lcp_images' => json_encode( [ (object) [ 'label' => 'lcp', diff --git a/tests/Fixtures/inc/Engine/Media/AboveTheFold/Frontend/Subscriber/HTML/output_w_beacon.html b/tests/Fixtures/inc/Engine/Media/AboveTheFold/Frontend/Subscriber/HTML/output_w_beacon.html index bf6f38a064..f2a858644b 100644 --- a/tests/Fixtures/inc/Engine/Media/AboveTheFold/Frontend/Subscriber/HTML/output_w_beacon.html +++ b/tests/Fixtures/inc/Engine/Media/AboveTheFold/Frontend/Subscriber/HTML/output_w_beacon.html @@ -3,5 +3,5 @@ Test - + diff --git a/tests/Unit/inc/Engine/Media/AboveTheFold/AJAX/Controller/addLcpData.php b/tests/Unit/inc/Engine/Media/AboveTheFold/AJAX/Controller/addLcpData.php index e02cfea9de..b866a64527 100644 --- a/tests/Unit/inc/Engine/Media/AboveTheFold/AJAX/Controller/addLcpData.php +++ b/tests/Unit/inc/Engine/Media/AboveTheFold/AJAX/Controller/addLcpData.php @@ -50,7 +50,7 @@ public function testShouldReturnExpected( $config, $expected ) { $_POST = [ 'url' => addslashes( $config['url'] ), 'is_mobile' => addslashes( $config['is_mobile'] ), - 'images' => addslashes( $config['images'] ), + 'lcp_images' => addslashes( $config['lcp_images'] ), 'status' => addslashes( $config['status'] ?? 'success' ), ]; From 3d80744dca79d46bec3f1ac6a2355f6092f70e3c Mon Sep 17 00:00:00 2001 From: Gael Robin Date: Wed, 17 Jul 2024 04:37:46 +0200 Subject: [PATCH 02/13] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 066a29c8f1..0c2e745e6b 100644 --- a/README.md +++ b/README.md @@ -43,8 +43,8 @@ To be able to validate your license and use the plugin, you will also have to ma | `gulp build:js:app:unmin` | Builds admin app js file, the unminified version (wpr-admin.js) | | `gulp build:js:app:min` | Builds admin app js file, the minified version (wpr-admin.min.js) | | `gulp build:js:lazyloadcss:min` | Builds lazyload CSS js file, the minified version (lazyload-css.min.js) | -| `gulp build:js:lcp:min` | Builds lcp beacon script, the minified version (lcp-beacon.min.js) | -| `gulp build:js:all` | Builds all js files mentioned above (wpr-admin.js, wpr-admin.min.js, lazyload-css.min.js, lcp-beacon.min.js) | +| `gulp build:js:lcp:min` | Builds lcp beacon script, the minified version (wpr-beacon.min.js) | +| `gulp build:js:all` | Builds all js files mentioned above (wpr-admin.js, wpr-admin.min.js, lazyload-css.min.js, wpr-beacon.min.js) | | `gulp js:watch` | Watches all js files changes and build them again with any change. | From 8a8e80b51f09555d1e4e2f84fa90b64682c05309 Mon Sep 17 00:00:00 2001 From: Gael Robin Date: Fri, 19 Jul 2024 02:57:28 +0200 Subject: [PATCH 03/13] refactor ajax action names --- assets/js/wpr-beacon.js | 16 +++++++-------- assets/js/wpr-beacon.min.js | 2 +- assets/js/wpr-beacon.min.js.map | 2 +- .../Media/AboveTheFold/AJAX/Controller.php | 16 +++++++-------- .../Media/AboveTheFold/AJAX/Subscriber.php | 20 +++++++++---------- .../AboveTheFold/Frontend/Controller.php | 6 +++--- .../{addLcpData.php => addBeaconData.php} | 0 .../{addLcpData.php => addBeaconData.php} | 0 .../{checkLcpData.php => checkBeaconData.php} | 12 +++++------ .../Subscriber/HTML/output_w_beacon.html | 2 +- ...disableImageDimensionsHeightPercentage.php | 2 +- .../{addLcpData.php => addBeaconData.php} | 10 +++++----- .../{checkLcpData.php => checkBeaconData.php} | 6 +++--- .../AboveTheFold/Frontend/Subscriber/lcp.php | 4 ++-- .../{addLcpData.php => addBeaconData.php} | 8 ++++---- 15 files changed, 53 insertions(+), 53 deletions(-) rename tests/Fixtures/inc/Engine/Media/AboveTheFold/AJAX/Controller/{addLcpData.php => addBeaconData.php} (100%) rename tests/Fixtures/inc/Engine/Media/AboveTheFold/AJAX/Subscriber/{addLcpData.php => addBeaconData.php} (100%) rename tests/Fixtures/inc/Engine/Media/AboveTheFold/AJAX/Subscriber/{checkLcpData.php => checkBeaconData.php} (80%) rename tests/Integration/inc/Engine/Media/AboveTheFold/AJAX/Subscriber/{addLcpData.php => addBeaconData.php} (83%) rename tests/Integration/inc/Engine/Media/AboveTheFold/AJAX/Subscriber/{checkLcpData.php => checkBeaconData.php} (90%) rename tests/Unit/inc/Engine/Media/AboveTheFold/AJAX/Controller/{addLcpData.php => addBeaconData.php} (95%) diff --git a/assets/js/wpr-beacon.js b/assets/js/wpr-beacon.js index 2d5590a191..a24e9b45eb 100644 --- a/assets/js/wpr-beacon.js +++ b/assets/js/wpr-beacon.js @@ -48,8 +48,8 @@ class RocketBeacon { async _isGeneratedBefore() { let data_check = new FormData(); - data_check.append('action', 'rocket_check_lcp'); - data_check.append('rocket_lcp_nonce', this.config.nonce); + data_check.append('action', 'rocket_check_beacon'); + data_check.append('rocket_beacon_nonce', this.config.nonce); data_check.append('url', this.config.url); data_check.append('is_mobile', this.config.is_mobile); @@ -87,8 +87,8 @@ class RocketBeacon { const lcpResults = this.lcpBeacon ? this.lcpBeacon.getResults() : null; const data = new FormData(); - data.append('action', 'rocket_lcp'); - data.append('rocket_lcp_nonce', this.config.nonce); + data.append('action', 'rocket_beacon'); + data.append('rocket_beacon_nonce', this.config.nonce); data.append('url', this.config.url); data.append('is_mobile', this.config.is_mobile); data.append('status', this._getFinalStatus()); @@ -145,23 +145,23 @@ class RocketBeacon { } static run() { - if (!window.rocket_lcp_data) { + if (!window.rocket_beacon_data) { return; } - const instance = new RocketBeacon(window.rocket_lcp_data); + const instance = new RocketBeacon(window.rocket_beacon_data); if (document.readyState !== 'loading') { setTimeout(() => { instance.init(); - }, window.rocket_lcp_data.delay); + }, window.rocket_beacon_data.delay); return; } document.addEventListener("DOMContentLoaded", () => { setTimeout(() => { instance.init(); - }, window.rocket_lcp_data.delay); + }, window.rocket_beacon_data.delay); }); } } diff --git a/assets/js/wpr-beacon.min.js b/assets/js/wpr-beacon.min.js index 763122d3d3..95da3a2107 100644 --- a/assets/js/wpr-beacon.min.js +++ b/assets/js/wpr-beacon.min.js @@ -1,2 +1,2 @@ -!function n(r,s,o){function c(t,e){if(!s[t]){if(!r[t]){var i="function"==typeof require&&require;if(!e&&i)return i(t,!0);if(a)return a(t,!0);throw(e=new Error("Cannot find module '"+t+"'")).code="MODULE_NOT_FOUND",e}i=s[t]={exports:{}},r[t][0].call(i.exports,function(e){return c(r[t][1][e]||e)},i,i.exports,n,r,s,o)}return s[t].exports}for(var a="function"==typeof require&&require,e=0;e{this._handleInfiniteLoop()},1e4),(await this._isGeneratedBefore()).lcp||(this.lcpBeacon=new r(this.config),await this.lcpBeacon.run()),this._saveFinalResultIntoDB()):this._finalize()}async _isValidPreconditions(){return this._isNotValidScreensize()?(this._logMessage("Bailing out because screen size is not acceptable"),!1):!this._isPageCached()||!await this._isGeneratedBefore()||(this._logMessage("Bailing out because data is already available"),!1)}_isPageCached(){var e=document.documentElement.nextSibling&&document.documentElement.nextSibling.data?document.documentElement.nextSibling.data:"";return e&&e.includes("Debug: cached")}async _isGeneratedBefore(){var e=new FormData,e=(e.append("action","rocket_check_lcp"),e.append("rocket_lcp_nonce",this.config.nonce),e.append("url",this.config.url),e.append("is_mobile",this.config.is_mobile),await fetch(this.config.ajax_url,{method:"POST",credentials:"same-origin",body:e}).then(e=>e.json()));return e.data}_isNotValidScreensize(){var e=window.innerWidth||document.documentElement.clientWidth,t=window.innerHeight||document.documentElement.clientHeight,i=this.config.is_mobile&&(e>this.config.width_threshold||t>this.config.height_threshold),e=!this.config.is_mobile&&(ee.json()).then(e=>{this._logMessage(e)}).catch(e=>{this._logMessage(e)}).finally(()=>{this._finalize()})}_getFinalStatus(){return""!==this.errorCode?this.errorCode:10<=(new Date-this.scriptTimer)/1e3?"timeout":"success"}_handleInfiniteLoop(){this._saveFinalResultIntoDB()}_finalize(){document.querySelector('[data-name="wpr-wpr-beacon"]').setAttribute("beacon-completed","true"),clearTimeout(this.infiniteLoopId)}_logMessage(e){this.config.debug&&console.log(e)}static run(){if(window.rocket_lcp_data){let e=new n(window.rocket_lcp_data);"loading"!==document.readyState?setTimeout(()=>{e.init()},window.rocket_lcp_data.delay):document.addEventListener("DOMContentLoaded",()=>{setTimeout(()=>{e.init()},window.rocket_lcp_data.delay)})}}}class r{constructor(e){this.config=e,this.performanceImages=[],this.errorCode=""}async run(){try{var e=this._generateLcpCandidates(1/0);e&&(this._initWithFirstElementWithInfo(e),this._fillATFWithoutDuplications(e))}catch(e){this.errorCode="script_error",this._logMessage("Script Error: "+e)}}_generateLcpCandidates(e){var t=document.querySelectorAll(this.config.elements);return t.length<=0?[]:Array.from(t).map(e=>{if("img"===e.nodeName.toLowerCase()&&"picture"===e.parentElement.nodeName.toLowerCase())return null;let t;if("picture"===e.nodeName.toLowerCase()){var i=e.querySelector("img");if(!i)return null;t=i.getBoundingClientRect()}else t=e.getBoundingClientRect();return{element:e,rect:t}}).filter(e=>null!==e).filter(e=>0({item:e,area:this._getElementArea(e.rect),elementInfo:this._getElementInfo(e.element)})).sort((e,t)=>t.area-e.area).slice(0,e).map(e=>({element:e.item.element,elementInfo:e.elementInfo}))}_getElementArea(e){return Math.min(e.width,(window.innerWidth||document.documentElement.clientWidth)-e.left)*Math.min(e.height,(window.innerHeight||document.documentElement.clientHeight)-e.top)}_getElementInfo(e){var t=e.nodeName.toLowerCase(),i={type:"",src:"",srcset:"",sizes:"",sources:[],bg_set:[],current_src:""};if("img"===t&&e.srcset)i.type="img-srcset",i.src=e.src,i.srcset=e.srcset,i.sizes=e.sizes,i.current_src=e.currentSrc;else if("img"===t)i.type="img",i.src=e.src,i.current_src=e.currentSrc;else if("video"===t){i.type="img";var n=e.querySelector("source");i.src=e.poster||(n?n.src:""),i.current_src=i.src}else if("svg"===t){n=e.querySelector("image");n&&(i.type="img",i.src=n.getAttribute("href")||"",i.current_src=i.src)}else if("picture"===t){i.type="picture";n=e.querySelector("img");i.src=n?n.src:"",i.sources=Array.from(e.querySelectorAll("source")).map(e=>({srcset:e.srcset||"",media:e.media||"",type:e.type||"",sizes:e.sizes||""}))}else{t=[window.getComputedStyle(e,null).getPropertyValue("background-image"),getComputedStyle(e,":after").getPropertyValue("background-image"),getComputedStyle(e,":before").getPropertyValue("background-image")].filter(e=>"none"!==e);if(0===t.length)return null;n=t[0];if(i.type="bg-img",n.includes("image-set(")&&(i.type="bg-img-set"),!n||""===n||n.includes("data:image"))return null;e=[...n.matchAll(/url\(\s*?['"]?\s*?(.+?)\s*?["']?\s*?\)/gi)];i.bg_set=e.map(e=>e[1]?{src:e[1].trim()+(e[2]?" "+e[2].trim():"")}:{}),i.bg_set.every(e=>""===e.src)&&(i.bg_set=e.map(e=>e[1]?{src:e[1].trim()}:{})),0null!==e.elementInfo);e?this.performanceImages=[{...e.elementInfo,label:"lcp"}]:(this._logMessage("No LCP candidate found."),this.performanceImages=[])}_fillATFWithoutDuplications(e){e.forEach(e=>{var{element:e,elementInfo:t}=e;!this._isDuplicateImage(e)&&t&&this.performanceImages.push({...t,label:"above-the-fold"})})}_isDuplicateImage(e){let t=this._getElementInfo(e);var i;return null!==t&&(e="img"===t.type||"img-srcset"===t.type||"video"===t.type,i="bg-img"===t.type||"bg-img-set"===t.type||"picture"===t.type,e||i)&&this.performanceImages.some(e=>e.src===t.src)}_logMessage(e){this.config.debug&&console.log(e)}getResults(){return this.performanceImages}}n.run()},{}]},{},[1]); +!function n(r,s,o){function a(t,e){if(!s[t]){if(!r[t]){var i="function"==typeof require&&require;if(!e&&i)return i(t,!0);if(c)return c(t,!0);throw(e=new Error("Cannot find module '"+t+"'")).code="MODULE_NOT_FOUND",e}i=s[t]={exports:{}},r[t][0].call(i.exports,function(e){return a(r[t][1][e]||e)},i,i.exports,n,r,s,o)}return s[t].exports}for(var c="function"==typeof require&&require,e=0;e{this._handleInfiniteLoop()},1e4),(await this._isGeneratedBefore()).lcp||(this.lcpBeacon=new r(this.config),await this.lcpBeacon.run()),this._saveFinalResultIntoDB()):this._finalize()}async _isValidPreconditions(){return this._isNotValidScreensize()?(this._logMessage("Bailing out because screen size is not acceptable"),!1):!this._isPageCached()||!await this._isGeneratedBefore()||(this._logMessage("Bailing out because data is already available"),!1)}_isPageCached(){var e=document.documentElement.nextSibling&&document.documentElement.nextSibling.data?document.documentElement.nextSibling.data:"";return e&&e.includes("Debug: cached")}async _isGeneratedBefore(){var e=new FormData,e=(e.append("action","rocket_check_beacon"),e.append("rocket_beacon_nonce",this.config.nonce),e.append("url",this.config.url),e.append("is_mobile",this.config.is_mobile),await fetch(this.config.ajax_url,{method:"POST",credentials:"same-origin",body:e}).then(e=>e.json()));return e.data}_isNotValidScreensize(){var e=window.innerWidth||document.documentElement.clientWidth,t=window.innerHeight||document.documentElement.clientHeight,i=this.config.is_mobile&&(e>this.config.width_threshold||t>this.config.height_threshold),e=!this.config.is_mobile&&(ee.json()).then(e=>{this._logMessage(e)}).catch(e=>{this._logMessage(e)}).finally(()=>{this._finalize()})}_getFinalStatus(){return""!==this.errorCode?this.errorCode:10<=(new Date-this.scriptTimer)/1e3?"timeout":"success"}_handleInfiniteLoop(){this._saveFinalResultIntoDB()}_finalize(){document.querySelector('[data-name="wpr-wpr-beacon"]').setAttribute("beacon-completed","true"),clearTimeout(this.infiniteLoopId)}_logMessage(e){this.config.debug&&console.log(e)}static run(){if(window.rocket_beacon_data){let e=new n(window.rocket_beacon_data);"loading"!==document.readyState?setTimeout(()=>{e.init()},window.rocket_beacon_data.delay):document.addEventListener("DOMContentLoaded",()=>{setTimeout(()=>{e.init()},window.rocket_beacon_data.delay)})}}}class r{constructor(e){this.config=e,this.performanceImages=[],this.errorCode=""}async run(){try{var e=this._generateLcpCandidates(1/0);e&&(this._initWithFirstElementWithInfo(e),this._fillATFWithoutDuplications(e))}catch(e){this.errorCode="script_error",this._logMessage("Script Error: "+e)}}_generateLcpCandidates(e){var t=document.querySelectorAll(this.config.elements);return t.length<=0?[]:Array.from(t).map(e=>{if("img"===e.nodeName.toLowerCase()&&"picture"===e.parentElement.nodeName.toLowerCase())return null;let t;if("picture"===e.nodeName.toLowerCase()){var i=e.querySelector("img");if(!i)return null;t=i.getBoundingClientRect()}else t=e.getBoundingClientRect();return{element:e,rect:t}}).filter(e=>null!==e).filter(e=>0({item:e,area:this._getElementArea(e.rect),elementInfo:this._getElementInfo(e.element)})).sort((e,t)=>t.area-e.area).slice(0,e).map(e=>({element:e.item.element,elementInfo:e.elementInfo}))}_getElementArea(e){return Math.min(e.width,(window.innerWidth||document.documentElement.clientWidth)-e.left)*Math.min(e.height,(window.innerHeight||document.documentElement.clientHeight)-e.top)}_getElementInfo(e){var t=e.nodeName.toLowerCase(),i={type:"",src:"",srcset:"",sizes:"",sources:[],bg_set:[],current_src:""};if("img"===t&&e.srcset)i.type="img-srcset",i.src=e.src,i.srcset=e.srcset,i.sizes=e.sizes,i.current_src=e.currentSrc;else if("img"===t)i.type="img",i.src=e.src,i.current_src=e.currentSrc;else if("video"===t){i.type="img";var n=e.querySelector("source");i.src=e.poster||(n?n.src:""),i.current_src=i.src}else if("svg"===t){n=e.querySelector("image");n&&(i.type="img",i.src=n.getAttribute("href")||"",i.current_src=i.src)}else if("picture"===t){i.type="picture";n=e.querySelector("img");i.src=n?n.src:"",i.sources=Array.from(e.querySelectorAll("source")).map(e=>({srcset:e.srcset||"",media:e.media||"",type:e.type||"",sizes:e.sizes||""}))}else{t=[window.getComputedStyle(e,null).getPropertyValue("background-image"),getComputedStyle(e,":after").getPropertyValue("background-image"),getComputedStyle(e,":before").getPropertyValue("background-image")].filter(e=>"none"!==e);if(0===t.length)return null;n=t[0];if(i.type="bg-img",n.includes("image-set(")&&(i.type="bg-img-set"),!n||""===n||n.includes("data:image"))return null;e=[...n.matchAll(/url\(\s*?['"]?\s*?(.+?)\s*?["']?\s*?\)/gi)];i.bg_set=e.map(e=>e[1]?{src:e[1].trim()+(e[2]?" "+e[2].trim():"")}:{}),i.bg_set.every(e=>""===e.src)&&(i.bg_set=e.map(e=>e[1]?{src:e[1].trim()}:{})),0null!==e.elementInfo);e?this.performanceImages=[{...e.elementInfo,label:"lcp"}]:(this._logMessage("No LCP candidate found."),this.performanceImages=[])}_fillATFWithoutDuplications(e){e.forEach(e=>{var{element:e,elementInfo:t}=e;!this._isDuplicateImage(e)&&t&&this.performanceImages.push({...t,label:"above-the-fold"})})}_isDuplicateImage(e){let t=this._getElementInfo(e);var i;return null!==t&&(e="img"===t.type||"img-srcset"===t.type||"video"===t.type,i="bg-img"===t.type||"bg-img-set"===t.type||"picture"===t.type,e||i)&&this.performanceImages.some(e=>e.src===t.src)}_logMessage(e){this.config.debug&&console.log(e)}getResults(){return this.performanceImages}}n.run()},{}]},{},[1]); //# sourceMappingURL=wpr-beacon.min.js.map diff --git a/assets/js/wpr-beacon.min.js.map b/assets/js/wpr-beacon.min.js.map index 17d8ecf9b1..c2ff8508a4 100644 --- a/assets/js/wpr-beacon.min.js.map +++ b/assets/js/wpr-beacon.min.js.map @@ -1 +1 @@ -{"version":3,"names":[],"mappings":"","sources":["wpr-beacon.min.js"],"sourcesContent":["!function n(r,s,o){function c(t,e){if(!s[t]){if(!r[t]){var i=\"function\"==typeof require&&require;if(!e&&i)return i(t,!0);if(a)return a(t,!0);throw(e=new Error(\"Cannot find module '\"+t+\"'\")).code=\"MODULE_NOT_FOUND\",e}i=s[t]={exports:{}},r[t][0].call(i.exports,function(e){return c(r[t][1][e]||e)},i,i.exports,n,r,s,o)}return s[t].exports}for(var a=\"function\"==typeof require&&require,e=0;e{this._handleInfiniteLoop()},1e4),(await this._isGeneratedBefore()).lcp||(this.lcpBeacon=new r(this.config),await this.lcpBeacon.run()),this._saveFinalResultIntoDB()):this._finalize()}async _isValidPreconditions(){return this._isNotValidScreensize()?(this._logMessage(\"Bailing out because screen size is not acceptable\"),!1):!this._isPageCached()||!await this._isGeneratedBefore()||(this._logMessage(\"Bailing out because data is already available\"),!1)}_isPageCached(){var e=document.documentElement.nextSibling&&document.documentElement.nextSibling.data?document.documentElement.nextSibling.data:\"\";return e&&e.includes(\"Debug: cached\")}async _isGeneratedBefore(){var e=new FormData,e=(e.append(\"action\",\"rocket_check_lcp\"),e.append(\"rocket_lcp_nonce\",this.config.nonce),e.append(\"url\",this.config.url),e.append(\"is_mobile\",this.config.is_mobile),await fetch(this.config.ajax_url,{method:\"POST\",credentials:\"same-origin\",body:e}).then(e=>e.json()));return e.data}_isNotValidScreensize(){var e=window.innerWidth||document.documentElement.clientWidth,t=window.innerHeight||document.documentElement.clientHeight,i=this.config.is_mobile&&(e>this.config.width_threshold||t>this.config.height_threshold),e=!this.config.is_mobile&&(ee.json()).then(e=>{this._logMessage(e)}).catch(e=>{this._logMessage(e)}).finally(()=>{this._finalize()})}_getFinalStatus(){return\"\"!==this.errorCode?this.errorCode:10<=(new Date-this.scriptTimer)/1e3?\"timeout\":\"success\"}_handleInfiniteLoop(){this._saveFinalResultIntoDB()}_finalize(){document.querySelector('[data-name=\"wpr-wpr-beacon\"]').setAttribute(\"beacon-completed\",\"true\"),clearTimeout(this.infiniteLoopId)}_logMessage(e){this.config.debug&&console.log(e)}static run(){if(window.rocket_lcp_data){let e=new n(window.rocket_lcp_data);\"loading\"!==document.readyState?setTimeout(()=>{e.init()},window.rocket_lcp_data.delay):document.addEventListener(\"DOMContentLoaded\",()=>{setTimeout(()=>{e.init()},window.rocket_lcp_data.delay)})}}}class r{constructor(e){this.config=e,this.performanceImages=[],this.errorCode=\"\"}async run(){try{var e=this._generateLcpCandidates(1/0);e&&(this._initWithFirstElementWithInfo(e),this._fillATFWithoutDuplications(e))}catch(e){this.errorCode=\"script_error\",this._logMessage(\"Script Error: \"+e)}}_generateLcpCandidates(e){var t=document.querySelectorAll(this.config.elements);return t.length<=0?[]:Array.from(t).map(e=>{if(\"img\"===e.nodeName.toLowerCase()&&\"picture\"===e.parentElement.nodeName.toLowerCase())return null;let t;if(\"picture\"===e.nodeName.toLowerCase()){var i=e.querySelector(\"img\");if(!i)return null;t=i.getBoundingClientRect()}else t=e.getBoundingClientRect();return{element:e,rect:t}}).filter(e=>null!==e).filter(e=>0({item:e,area:this._getElementArea(e.rect),elementInfo:this._getElementInfo(e.element)})).sort((e,t)=>t.area-e.area).slice(0,e).map(e=>({element:e.item.element,elementInfo:e.elementInfo}))}_getElementArea(e){return Math.min(e.width,(window.innerWidth||document.documentElement.clientWidth)-e.left)*Math.min(e.height,(window.innerHeight||document.documentElement.clientHeight)-e.top)}_getElementInfo(e){var t=e.nodeName.toLowerCase(),i={type:\"\",src:\"\",srcset:\"\",sizes:\"\",sources:[],bg_set:[],current_src:\"\"};if(\"img\"===t&&e.srcset)i.type=\"img-srcset\",i.src=e.src,i.srcset=e.srcset,i.sizes=e.sizes,i.current_src=e.currentSrc;else if(\"img\"===t)i.type=\"img\",i.src=e.src,i.current_src=e.currentSrc;else if(\"video\"===t){i.type=\"img\";var n=e.querySelector(\"source\");i.src=e.poster||(n?n.src:\"\"),i.current_src=i.src}else if(\"svg\"===t){n=e.querySelector(\"image\");n&&(i.type=\"img\",i.src=n.getAttribute(\"href\")||\"\",i.current_src=i.src)}else if(\"picture\"===t){i.type=\"picture\";n=e.querySelector(\"img\");i.src=n?n.src:\"\",i.sources=Array.from(e.querySelectorAll(\"source\")).map(e=>({srcset:e.srcset||\"\",media:e.media||\"\",type:e.type||\"\",sizes:e.sizes||\"\"}))}else{t=[window.getComputedStyle(e,null).getPropertyValue(\"background-image\"),getComputedStyle(e,\":after\").getPropertyValue(\"background-image\"),getComputedStyle(e,\":before\").getPropertyValue(\"background-image\")].filter(e=>\"none\"!==e);if(0===t.length)return null;n=t[0];if(i.type=\"bg-img\",n.includes(\"image-set(\")&&(i.type=\"bg-img-set\"),!n||\"\"===n||n.includes(\"data:image\"))return null;e=[...n.matchAll(/url\\(\\s*?['\"]?\\s*?(.+?)\\s*?[\"']?\\s*?\\)/gi)];i.bg_set=e.map(e=>e[1]?{src:e[1].trim()+(e[2]?\" \"+e[2].trim():\"\")}:{}),i.bg_set.every(e=>\"\"===e.src)&&(i.bg_set=e.map(e=>e[1]?{src:e[1].trim()}:{})),0null!==e.elementInfo);e?this.performanceImages=[{...e.elementInfo,label:\"lcp\"}]:(this._logMessage(\"No LCP candidate found.\"),this.performanceImages=[])}_fillATFWithoutDuplications(e){e.forEach(e=>{var{element:e,elementInfo:t}=e;!this._isDuplicateImage(e)&&t&&this.performanceImages.push({...t,label:\"above-the-fold\"})})}_isDuplicateImage(e){let t=this._getElementInfo(e);var i;return null!==t&&(e=\"img\"===t.type||\"img-srcset\"===t.type||\"video\"===t.type,i=\"bg-img\"===t.type||\"bg-img-set\"===t.type||\"picture\"===t.type,e||i)&&this.performanceImages.some(e=>e.src===t.src)}_logMessage(e){this.config.debug&&console.log(e)}getResults(){return this.performanceImages}}n.run()},{}]},{},[1]);"],"file":"wpr-beacon.min.js"} \ No newline at end of file +{"version":3,"names":[],"mappings":"","sources":["wpr-beacon.min.js"],"sourcesContent":["!function n(r,s,o){function a(t,e){if(!s[t]){if(!r[t]){var i=\"function\"==typeof require&&require;if(!e&&i)return i(t,!0);if(c)return c(t,!0);throw(e=new Error(\"Cannot find module '\"+t+\"'\")).code=\"MODULE_NOT_FOUND\",e}i=s[t]={exports:{}},r[t][0].call(i.exports,function(e){return a(r[t][1][e]||e)},i,i.exports,n,r,s,o)}return s[t].exports}for(var c=\"function\"==typeof require&&require,e=0;e{this._handleInfiniteLoop()},1e4),(await this._isGeneratedBefore()).lcp||(this.lcpBeacon=new r(this.config),await this.lcpBeacon.run()),this._saveFinalResultIntoDB()):this._finalize()}async _isValidPreconditions(){return this._isNotValidScreensize()?(this._logMessage(\"Bailing out because screen size is not acceptable\"),!1):!this._isPageCached()||!await this._isGeneratedBefore()||(this._logMessage(\"Bailing out because data is already available\"),!1)}_isPageCached(){var e=document.documentElement.nextSibling&&document.documentElement.nextSibling.data?document.documentElement.nextSibling.data:\"\";return e&&e.includes(\"Debug: cached\")}async _isGeneratedBefore(){var e=new FormData,e=(e.append(\"action\",\"rocket_check_beacon\"),e.append(\"rocket_beacon_nonce\",this.config.nonce),e.append(\"url\",this.config.url),e.append(\"is_mobile\",this.config.is_mobile),await fetch(this.config.ajax_url,{method:\"POST\",credentials:\"same-origin\",body:e}).then(e=>e.json()));return e.data}_isNotValidScreensize(){var e=window.innerWidth||document.documentElement.clientWidth,t=window.innerHeight||document.documentElement.clientHeight,i=this.config.is_mobile&&(e>this.config.width_threshold||t>this.config.height_threshold),e=!this.config.is_mobile&&(ee.json()).then(e=>{this._logMessage(e)}).catch(e=>{this._logMessage(e)}).finally(()=>{this._finalize()})}_getFinalStatus(){return\"\"!==this.errorCode?this.errorCode:10<=(new Date-this.scriptTimer)/1e3?\"timeout\":\"success\"}_handleInfiniteLoop(){this._saveFinalResultIntoDB()}_finalize(){document.querySelector('[data-name=\"wpr-wpr-beacon\"]').setAttribute(\"beacon-completed\",\"true\"),clearTimeout(this.infiniteLoopId)}_logMessage(e){this.config.debug&&console.log(e)}static run(){if(window.rocket_beacon_data){let e=new n(window.rocket_beacon_data);\"loading\"!==document.readyState?setTimeout(()=>{e.init()},window.rocket_beacon_data.delay):document.addEventListener(\"DOMContentLoaded\",()=>{setTimeout(()=>{e.init()},window.rocket_beacon_data.delay)})}}}class r{constructor(e){this.config=e,this.performanceImages=[],this.errorCode=\"\"}async run(){try{var e=this._generateLcpCandidates(1/0);e&&(this._initWithFirstElementWithInfo(e),this._fillATFWithoutDuplications(e))}catch(e){this.errorCode=\"script_error\",this._logMessage(\"Script Error: \"+e)}}_generateLcpCandidates(e){var t=document.querySelectorAll(this.config.elements);return t.length<=0?[]:Array.from(t).map(e=>{if(\"img\"===e.nodeName.toLowerCase()&&\"picture\"===e.parentElement.nodeName.toLowerCase())return null;let t;if(\"picture\"===e.nodeName.toLowerCase()){var i=e.querySelector(\"img\");if(!i)return null;t=i.getBoundingClientRect()}else t=e.getBoundingClientRect();return{element:e,rect:t}}).filter(e=>null!==e).filter(e=>0({item:e,area:this._getElementArea(e.rect),elementInfo:this._getElementInfo(e.element)})).sort((e,t)=>t.area-e.area).slice(0,e).map(e=>({element:e.item.element,elementInfo:e.elementInfo}))}_getElementArea(e){return Math.min(e.width,(window.innerWidth||document.documentElement.clientWidth)-e.left)*Math.min(e.height,(window.innerHeight||document.documentElement.clientHeight)-e.top)}_getElementInfo(e){var t=e.nodeName.toLowerCase(),i={type:\"\",src:\"\",srcset:\"\",sizes:\"\",sources:[],bg_set:[],current_src:\"\"};if(\"img\"===t&&e.srcset)i.type=\"img-srcset\",i.src=e.src,i.srcset=e.srcset,i.sizes=e.sizes,i.current_src=e.currentSrc;else if(\"img\"===t)i.type=\"img\",i.src=e.src,i.current_src=e.currentSrc;else if(\"video\"===t){i.type=\"img\";var n=e.querySelector(\"source\");i.src=e.poster||(n?n.src:\"\"),i.current_src=i.src}else if(\"svg\"===t){n=e.querySelector(\"image\");n&&(i.type=\"img\",i.src=n.getAttribute(\"href\")||\"\",i.current_src=i.src)}else if(\"picture\"===t){i.type=\"picture\";n=e.querySelector(\"img\");i.src=n?n.src:\"\",i.sources=Array.from(e.querySelectorAll(\"source\")).map(e=>({srcset:e.srcset||\"\",media:e.media||\"\",type:e.type||\"\",sizes:e.sizes||\"\"}))}else{t=[window.getComputedStyle(e,null).getPropertyValue(\"background-image\"),getComputedStyle(e,\":after\").getPropertyValue(\"background-image\"),getComputedStyle(e,\":before\").getPropertyValue(\"background-image\")].filter(e=>\"none\"!==e);if(0===t.length)return null;n=t[0];if(i.type=\"bg-img\",n.includes(\"image-set(\")&&(i.type=\"bg-img-set\"),!n||\"\"===n||n.includes(\"data:image\"))return null;e=[...n.matchAll(/url\\(\\s*?['\"]?\\s*?(.+?)\\s*?[\"']?\\s*?\\)/gi)];i.bg_set=e.map(e=>e[1]?{src:e[1].trim()+(e[2]?\" \"+e[2].trim():\"\")}:{}),i.bg_set.every(e=>\"\"===e.src)&&(i.bg_set=e.map(e=>e[1]?{src:e[1].trim()}:{})),0null!==e.elementInfo);e?this.performanceImages=[{...e.elementInfo,label:\"lcp\"}]:(this._logMessage(\"No LCP candidate found.\"),this.performanceImages=[])}_fillATFWithoutDuplications(e){e.forEach(e=>{var{element:e,elementInfo:t}=e;!this._isDuplicateImage(e)&&t&&this.performanceImages.push({...t,label:\"above-the-fold\"})})}_isDuplicateImage(e){let t=this._getElementInfo(e);var i;return null!==t&&(e=\"img\"===t.type||\"img-srcset\"===t.type||\"video\"===t.type,i=\"bg-img\"===t.type||\"bg-img-set\"===t.type||\"picture\"===t.type,e||i)&&this.performanceImages.some(e=>e.src===t.src)}_logMessage(e){this.config.debug&&console.log(e)}getResults(){return this.performanceImages}}n.run()},{}]},{},[1]);"],"file":"wpr-beacon.min.js"} \ No newline at end of file diff --git a/inc/Engine/Media/AboveTheFold/AJAX/Controller.php b/inc/Engine/Media/AboveTheFold/AJAX/Controller.php index 8b44147436..6c1acb60eb 100644 --- a/inc/Engine/Media/AboveTheFold/AJAX/Controller.php +++ b/inc/Engine/Media/AboveTheFold/AJAX/Controller.php @@ -49,8 +49,8 @@ public function __construct( ATFQuery $query, ContextInterface $context ) { * * @return bool */ - public function add_lcp_data() { - check_ajax_referer( 'rocket_lcp', 'rocket_lcp_nonce' ); + public function add_beacon_data() { + check_ajax_referer( 'rocket_beacon', 'rocket_beacon_nonce' ); if ( ! $this->context->is_allowed() ) { wp_send_json_error( 'not allowed' ); @@ -240,7 +240,7 @@ private function sanitize_image_url( string $url ) { } /** - * Checks if there is existing LCP data for the current URL and device type. + * Checks if there is existing data for the current URL and device type from the beacon script. * * This method is called via AJAX. It checks if there is existing LCP data for the current URL and device type. * If the data exists, it returns a JSON success response with true. If the data does not exist, it returns a JSON success response with false. @@ -248,8 +248,8 @@ private function sanitize_image_url( string $url ) { * * @return void */ - public function check_lcp_data() { - check_ajax_referer( 'rocket_lcp', 'rocket_lcp_nonce' ); + public function check_beacon_data(): void { + check_ajax_referer( 'rocket_beacon', 'rocket_beacon_nonce' ); if ( ! $this->context->is_allowed() ) { wp_send_json_error( false ); @@ -275,8 +275,8 @@ public function check_lcp_data() { * @param object $image_object Image full object. * @return bool */ - private function validate_image( $image_object ) { - $valid_image = ! empty( $image_object->src ) ? $this->validate_image_src( $image_object->src ?? '' ) : true; + private function validate_image( object $image_object ): bool { + $valid_image = empty( $image_object->src ) || $this->validate_image_src( $image_object->src ?? '' ); /** * Filters If the image src is a valid image or not. @@ -294,7 +294,7 @@ private function validate_image( $image_object ) { * @param string $image_src Image src url. * @return bool */ - private function validate_image_src( $image_src ) { + private function validate_image_src( string $image_src ): bool { if ( empty( $image_src ) ) { return false; } diff --git a/inc/Engine/Media/AboveTheFold/AJAX/Subscriber.php b/inc/Engine/Media/AboveTheFold/AJAX/Subscriber.php index 6a070c454b..64d41b8ab7 100644 --- a/inc/Engine/Media/AboveTheFold/AJAX/Subscriber.php +++ b/inc/Engine/Media/AboveTheFold/AJAX/Subscriber.php @@ -29,28 +29,28 @@ public function __construct( Controller $controller ) { */ public static function get_subscribed_events() { return [ - 'wp_ajax_rocket_lcp' => 'add_lcp_data', - 'wp_ajax_nopriv_rocket_lcp' => 'add_lcp_data', - 'wp_ajax_rocket_check_lcp' => 'check_lcp_data', - 'wp_ajax_nopriv_rocket_check_lcp' => 'check_lcp_data', + 'wp_ajax_rocket_beacon' => 'add_beacon_data', + 'wp_ajax_nopriv_rocket_beacon' => 'add_beacon_data', + 'wp_ajax_rocket_check_beacon' => 'check_beacon_data', + 'wp_ajax_nopriv_rocket_check_beacon' => 'check_beacon_data', ]; } /** - * Callback for data received from lcp script + * Callback for data received from beacon script * * @return void */ - public function add_lcp_data() { - $this->controller->add_lcp_data(); + public function add_beacon_data() { + $this->controller->add_beacon_data(); } /** - * Callback for checking lcp data + * Callback for checking datas from beacon * * @return void */ - public function check_lcp_data() { - $this->controller->check_lcp_data(); + public function check_beacon_data() { + $this->controller->check_beacon_data(); } } diff --git a/inc/Engine/Media/AboveTheFold/Frontend/Controller.php b/inc/Engine/Media/AboveTheFold/Frontend/Controller.php index 054705a008..5e2006ceb0 100644 --- a/inc/Engine/Media/AboveTheFold/Frontend/Controller.php +++ b/inc/Engine/Media/AboveTheFold/Frontend/Controller.php @@ -412,7 +412,7 @@ public function inject_beacon( $html, $url, $is_mobile ): string { * * @param int $delay The delay in milliseconds. Default is 500. */ - $delay = apply_filters( 'rocket_lcp_delay', $default_delay ); + $delay = apply_filters( 'rocket_beacon_delay', $default_delay ); if ( ! is_int( $delay ) ) { $delay = $default_delay; @@ -420,7 +420,7 @@ public function inject_beacon( $html, $url, $is_mobile ): string { $data = [ 'ajax_url' => admin_url( 'admin-ajax.php' ), - 'nonce' => wp_create_nonce( 'rocket_lcp' ), + 'nonce' => wp_create_nonce( 'rocket_beacon' ), 'url' => $url, 'is_mobile' => $is_mobile, 'elements' => $this->lcp_atf_elements(), @@ -430,7 +430,7 @@ public function inject_beacon( $html, $url, $is_mobile ): string { 'debug' => rocket_get_constant( 'WP_ROCKET_DEBUG' ), ]; - $inline_script = ''; + $inline_script = ''; // Get the URL of the script. $script_url = rocket_get_constant( 'WP_ROCKET_ASSETS_JS_URL' ) . 'wpr-beacon' . $min . '.js'; diff --git a/tests/Fixtures/inc/Engine/Media/AboveTheFold/AJAX/Controller/addLcpData.php b/tests/Fixtures/inc/Engine/Media/AboveTheFold/AJAX/Controller/addBeaconData.php similarity index 100% rename from tests/Fixtures/inc/Engine/Media/AboveTheFold/AJAX/Controller/addLcpData.php rename to tests/Fixtures/inc/Engine/Media/AboveTheFold/AJAX/Controller/addBeaconData.php diff --git a/tests/Fixtures/inc/Engine/Media/AboveTheFold/AJAX/Subscriber/addLcpData.php b/tests/Fixtures/inc/Engine/Media/AboveTheFold/AJAX/Subscriber/addBeaconData.php similarity index 100% rename from tests/Fixtures/inc/Engine/Media/AboveTheFold/AJAX/Subscriber/addLcpData.php rename to tests/Fixtures/inc/Engine/Media/AboveTheFold/AJAX/Subscriber/addBeaconData.php diff --git a/tests/Fixtures/inc/Engine/Media/AboveTheFold/AJAX/Subscriber/checkLcpData.php b/tests/Fixtures/inc/Engine/Media/AboveTheFold/AJAX/Subscriber/checkBeaconData.php similarity index 80% rename from tests/Fixtures/inc/Engine/Media/AboveTheFold/AJAX/Subscriber/checkLcpData.php rename to tests/Fixtures/inc/Engine/Media/AboveTheFold/AJAX/Subscriber/checkBeaconData.php index 61a65ae4b2..3a3caf2c75 100644 --- a/tests/Fixtures/inc/Engine/Media/AboveTheFold/AJAX/Subscriber/checkLcpData.php +++ b/tests/Fixtures/inc/Engine/Media/AboveTheFold/AJAX/Subscriber/checkBeaconData.php @@ -7,8 +7,8 @@ 'url' => 'http://example.org', 'is_mobile' => false, 'post' => [ - 'rocket_lcp_nonce' => wp_create_nonce( 'rocket_lcp' ), - 'action' => 'rocket_check_lcp', + 'rocket_beacon_nonce' => wp_create_nonce( 'rocket_beacon' ), + 'action' => 'rocket_check_beacon', 'url' => 'http://example.org', 'is_mobile' => false, ], @@ -24,8 +24,8 @@ 'url' => 'http://example.org', 'is_mobile' => false, 'post' => [ - 'rocket_lcp_nonce' => wp_create_nonce( 'rocket_lcp' ), - 'action' => 'rocket_check_lcp', + 'rocket_beacon_nonce' => wp_create_nonce( 'rocket_beacon' ), + 'action' => 'rocket_check_beacon', 'url' => 'http://example.org', 'is_mobile' => false, ], @@ -55,8 +55,8 @@ 'url' => 'http://example.org', 'is_mobile' => false, 'post' => [ - 'rocket_lcp_nonce' => wp_create_nonce( 'rocket_lcp' ), - 'action' => 'rocket_check_lcp', + 'rocket_beacon_nonce' => wp_create_nonce( 'rocket_beacon' ), + 'action' => 'rocket_check_beacon', 'url' => 'http://example.org', 'is_mobile' => false, ], diff --git a/tests/Fixtures/inc/Engine/Media/AboveTheFold/Frontend/Subscriber/HTML/output_w_beacon.html b/tests/Fixtures/inc/Engine/Media/AboveTheFold/Frontend/Subscriber/HTML/output_w_beacon.html index f2a858644b..ddbf862a86 100644 --- a/tests/Fixtures/inc/Engine/Media/AboveTheFold/Frontend/Subscriber/HTML/output_w_beacon.html +++ b/tests/Fixtures/inc/Engine/Media/AboveTheFold/Frontend/Subscriber/HTML/output_w_beacon.html @@ -3,5 +3,5 @@ Test - + diff --git a/tests/Fixtures/inc/ThirdParty/Themes/Divi/Integration/disableImageDimensionsHeightPercentage.php b/tests/Fixtures/inc/ThirdParty/Themes/Divi/Integration/disableImageDimensionsHeightPercentage.php index df47d5c52c..ea7ca34b84 100644 --- a/tests/Fixtures/inc/ThirdParty/Themes/Divi/Integration/disableImageDimensionsHeightPercentage.php +++ b/tests/Fixtures/inc/ThirdParty/Themes/Divi/Integration/disableImageDimensionsHeightPercentage.php @@ -11,7 +11,7 @@ ORIGINALHTML; -$nonce = wp_create_nonce( 'rocket_lcp' ); +$nonce = wp_create_nonce( 'rocket_beacon' ); $expected_html = << diff --git a/tests/Integration/inc/Engine/Media/AboveTheFold/AJAX/Subscriber/addLcpData.php b/tests/Integration/inc/Engine/Media/AboveTheFold/AJAX/Subscriber/addBeaconData.php similarity index 83% rename from tests/Integration/inc/Engine/Media/AboveTheFold/AJAX/Subscriber/addLcpData.php rename to tests/Integration/inc/Engine/Media/AboveTheFold/AJAX/Subscriber/addBeaconData.php index 3dda20d1e9..c215f820d6 100644 --- a/tests/Integration/inc/Engine/Media/AboveTheFold/AJAX/Subscriber/addLcpData.php +++ b/tests/Integration/inc/Engine/Media/AboveTheFold/AJAX/Subscriber/addBeaconData.php @@ -5,11 +5,11 @@ use WP_Rocket\Tests\Integration\AjaxTestCase; /** - * Test class covering WP_Rocket\Engine\Media\AboveTheFold\AJAX\Subscriber::add_lcp_data + * Test class covering WP_Rocket\Engine\Media\AboveTheFold\AJAX\Subscriber::add_beacon_data * * @group AboveTheFold */ -class Test_AddLcpData extends AjaxTestCase { +class Test_AddBeaconData extends AjaxTestCase { private $allowed; public function set_up() { @@ -17,7 +17,7 @@ public function set_up() { self::installAtfTable(); - $this->action = 'rocket_lcp'; + $this->action = 'rocket_beacon'; } /** @@ -37,8 +37,8 @@ public function tear_down() { * @dataProvider configTestData */ public function testShouldReturnExpected( $config, $expected ) { - $_POST['rocket_lcp_nonce'] = wp_create_nonce( 'rocket_lcp' ); - $_POST['action'] = 'rocket_lcp'; + $_POST['rocket_beacon_nonce'] = wp_create_nonce( 'rocket_beacon' ); + $_POST['action'] = 'rocket_beacon'; $_POST['url'] = $config['url']; $_POST['is_mobile'] = $config['is_mobile']; $_POST['images'] = $config['images']; diff --git a/tests/Integration/inc/Engine/Media/AboveTheFold/AJAX/Subscriber/checkLcpData.php b/tests/Integration/inc/Engine/Media/AboveTheFold/AJAX/Subscriber/checkBeaconData.php similarity index 90% rename from tests/Integration/inc/Engine/Media/AboveTheFold/AJAX/Subscriber/checkLcpData.php rename to tests/Integration/inc/Engine/Media/AboveTheFold/AJAX/Subscriber/checkBeaconData.php index 4c854aa72c..cb46dc2fca 100644 --- a/tests/Integration/inc/Engine/Media/AboveTheFold/AJAX/Subscriber/checkLcpData.php +++ b/tests/Integration/inc/Engine/Media/AboveTheFold/AJAX/Subscriber/checkBeaconData.php @@ -5,11 +5,11 @@ use WP_Rocket\Tests\Integration\AjaxTestCase; /** - * @covers WP_Rocket\Engine\Media\AboveTheFold\AJAX\Subscriber::check_lcp_data + * @covers WP_Rocket\Engine\Media\AboveTheFold\AJAX\Subscriber::check_beacon_data * * @group AboveTheFold */ -class Test_CheckLcpData extends AjaxTestCase { +class Test_CheckBeaconData extends AjaxTestCase { private $allowed; public function set_up() { @@ -17,7 +17,7 @@ public function set_up() { self::installAtfTable(); - $this->action = 'rocket_check_lcp'; + $this->action = 'rocket_check_beacon'; } /** diff --git a/tests/Integration/inc/Engine/Media/AboveTheFold/Frontend/Subscriber/lcp.php b/tests/Integration/inc/Engine/Media/AboveTheFold/Frontend/Subscriber/lcp.php index a476ba03e4..d4c008990c 100644 --- a/tests/Integration/inc/Engine/Media/AboveTheFold/Frontend/Subscriber/lcp.php +++ b/tests/Integration/inc/Engine/Media/AboveTheFold/Frontend/Subscriber/lcp.php @@ -26,7 +26,7 @@ public function set_up() { public function tear_down() { self::uninstallAtfTable(); - remove_filter( 'rocket_lcp_delay', [ $this, 'add_delay' ] ); + remove_filter( 'rocket_beacon_delay', [ $this, 'add_delay' ] ); $this->restoreWpHook( 'rocket_buffer' ); parent::tear_down(); @@ -43,7 +43,7 @@ public function testShouldReturnAsExpected( $config, $expected ) { } if ( isset( $config['filter_delay'] ) ) { - add_filter( 'rocket_lcp_delay', [ $this, 'add_delay' ] ); + add_filter( 'rocket_beacon_delay', [ $this, 'add_delay' ] ); } Functions\when( 'wp_create_nonce' )->justReturn( '96ac96b69e' ); diff --git a/tests/Unit/inc/Engine/Media/AboveTheFold/AJAX/Controller/addLcpData.php b/tests/Unit/inc/Engine/Media/AboveTheFold/AJAX/Controller/addBeaconData.php similarity index 95% rename from tests/Unit/inc/Engine/Media/AboveTheFold/AJAX/Controller/addLcpData.php rename to tests/Unit/inc/Engine/Media/AboveTheFold/AJAX/Controller/addBeaconData.php index b866a64527..f02016c245 100644 --- a/tests/Unit/inc/Engine/Media/AboveTheFold/AJAX/Controller/addLcpData.php +++ b/tests/Unit/inc/Engine/Media/AboveTheFold/AJAX/Controller/addBeaconData.php @@ -11,11 +11,11 @@ use Brain\Monkey\Filters; /** - * Test class covering WP_Rocket\Engine\Media\AboveTheFold\AJAX\Controller::add_lcp_data + * Test class covering WP_Rocket\Engine\Media\AboveTheFold\AJAX\Controller::add_beacon_data * * @group AboveTheFold */ -class Test_AddLcpData extends TestCase { +class Test_AddBeaconData extends TestCase { private $query; private $controller; private $context; @@ -56,7 +56,7 @@ public function testShouldReturnExpected( $config, $expected ) { Functions\expect( 'check_ajax_referer' ) ->once() - ->with( 'rocket_lcp', 'rocket_lcp_nonce' ) + ->with( 'rocket_beacon', 'rocket_beacon_nonce' ) ->andReturn( true ); $this->context->shouldReceive( 'is_allowed' ) @@ -118,6 +118,6 @@ function( $url ) use ( $images_valid_sources ) { Functions\when('wp_check_filetype')->justReturn( $config['filetype'] ); } - $this->controller->add_lcp_data(); + $this->controller->add_beacon_data(); } } From 46cacb558f23fca8039515e51a6b6153df62a47a Mon Sep 17 00:00:00 2001 From: Gael Robin Date: Mon, 22 Jul 2024 02:14:45 +0200 Subject: [PATCH 04/13] Adds `apply_filters_deprecated` --- inc/Engine/Media/AboveTheFold/Frontend/Controller.php | 1 + 1 file changed, 1 insertion(+) diff --git a/inc/Engine/Media/AboveTheFold/Frontend/Controller.php b/inc/Engine/Media/AboveTheFold/Frontend/Controller.php index 5e2006ceb0..61c2a2c6b6 100644 --- a/inc/Engine/Media/AboveTheFold/Frontend/Controller.php +++ b/inc/Engine/Media/AboveTheFold/Frontend/Controller.php @@ -407,6 +407,7 @@ public function inject_beacon( $html, $url, $is_mobile ): string { $default_delay = 500; + $delay = apply_filters_deprecated( 'rocket_lcp_delay', [ $default_delay ], '3.17', 'rocket_beacon_delay' ); /** * Filters the delay before the LCP beacon is triggered. * From 9d3ce320615abc1d6b34dc58b6120e70bf547c75 Mon Sep 17 00:00:00 2001 From: Gael Robin Date: Tue, 23 Jul 2024 02:56:21 +0200 Subject: [PATCH 05/13] Update test `checkData` --- .../Common/PerformanceHints/AJAX/Subscriber/checkData.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tests/Integration/inc/Engine/Common/PerformanceHints/AJAX/Subscriber/checkData.php b/tests/Integration/inc/Engine/Common/PerformanceHints/AJAX/Subscriber/checkData.php index 65bafe3bda..e66b937040 100644 --- a/tests/Integration/inc/Engine/Common/PerformanceHints/AJAX/Subscriber/checkData.php +++ b/tests/Integration/inc/Engine/Common/PerformanceHints/AJAX/Subscriber/checkData.php @@ -5,19 +5,11 @@ use WP_Rocket\Tests\Integration\AjaxTestCase; /** -<<<<<<<< HEAD:tests/Integration/inc/Engine/Common/PerformanceHints/AJAX/Subscriber/checkBeaconData.php - * @covers WP_Rocket\Engine\Media\AboveTheFold\AJAX\Subscriber::check_beacon_data -======== * @covers WP_Rocket\Engine\Common\PerformanceHints\AJAX\Subscriber::check_data ->>>>>>>> 3.17-atf-refactor:tests/Integration/inc/Engine/Common/PerformanceHints/AJAX/Subscriber/checkData.php * * @group PerformanceHints */ -<<<<<<<< HEAD:tests/Integration/inc/Engine/Common/PerformanceHints/AJAX/Subscriber/checkBeaconData.php -class Test_CheckBeaconData extends AjaxTestCase { -======== class Test_CheckData extends AjaxTestCase { ->>>>>>>> 3.17-atf-refactor:tests/Integration/inc/Engine/Common/PerformanceHints/AJAX/Subscriber/checkData.php private $allowed; public function set_up() { From bc14207a2ef291e1f3b3f4c6494895f3143f9d78 Mon Sep 17 00:00:00 2001 From: Gael Robin Date: Tue, 23 Jul 2024 03:00:46 +0200 Subject: [PATCH 06/13] Update test `addData` --- .../Common/PerformanceHints/AJAX/Subscriber/addData.php | 8 -------- .../Engine/Media/AboveTheFold/AJAX/Controller/addData.php | 6 +----- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/tests/Integration/inc/Engine/Common/PerformanceHints/AJAX/Subscriber/addData.php b/tests/Integration/inc/Engine/Common/PerformanceHints/AJAX/Subscriber/addData.php index aa7cc5be76..c14020831c 100644 --- a/tests/Integration/inc/Engine/Common/PerformanceHints/AJAX/Subscriber/addData.php +++ b/tests/Integration/inc/Engine/Common/PerformanceHints/AJAX/Subscriber/addData.php @@ -5,19 +5,11 @@ use WP_Rocket\Tests\Integration\AjaxTestCase; /** -<<<<<<<< HEAD:tests/Integration/inc/Engine/Common/PerformanceHints/AJAX/Subscriber/addBeaconData.php - * Test class covering WP_Rocket\Engine\Media\AboveTheFold\AJAX\Subscriber::add_beacon_data -======== * Test class covering WP_Rocket\Engine\Common\PerformanceHints\AJAX\Subscriber::add_data ->>>>>>>> 3.17-atf-refactor:tests/Integration/inc/Engine/Common/PerformanceHints/AJAX/Subscriber/addData.php * * @group PerformanceHints */ -<<<<<<<< HEAD:tests/Integration/inc/Engine/Common/PerformanceHints/AJAX/Subscriber/addBeaconData.php -class Test_AddBeaconData extends AjaxTestCase { -======== class Test_AddData extends AjaxTestCase { ->>>>>>>> 3.17-atf-refactor:tests/Integration/inc/Engine/Common/PerformanceHints/AJAX/Subscriber/addData.php private $allowed; public function set_up() { diff --git a/tests/Unit/inc/Engine/Media/AboveTheFold/AJAX/Controller/addData.php b/tests/Unit/inc/Engine/Media/AboveTheFold/AJAX/Controller/addData.php index 3083f2aa1b..b539e6a8e9 100644 --- a/tests/Unit/inc/Engine/Media/AboveTheFold/AJAX/Controller/addData.php +++ b/tests/Unit/inc/Engine/Media/AboveTheFold/AJAX/Controller/addData.php @@ -11,7 +11,7 @@ use Brain\Monkey\Filters; /** - * Test class covering WP_Rocket\Engine\Media\AboveTheFold\AJAX\Controller::add_beacon_data + * Test class covering WP_Rocket\Engine\Media\AboveTheFold\AJAX\Controller::add_data * * @group AboveTheFold */ @@ -118,10 +118,6 @@ function( $url ) use ( $images_valid_sources ) { Functions\when('wp_check_filetype')->justReturn( $config['filetype'] ); } -<<<<<<<< HEAD:tests/Unit/inc/Engine/Media/AboveTheFold/AJAX/Controller/addBeaconData.php - $this->controller->add_beacon_data(); -======== $this->controller->add_data(); ->>>>>>>> 3.17-atf-refactor:tests/Unit/inc/Engine/Media/AboveTheFold/AJAX/Controller/addData.php } } From cb09ea6f70dbdec65fcaeaf5c3a411ef315da483 Mon Sep 17 00:00:00 2001 From: Gael Robin Date: Tue, 23 Jul 2024 04:37:34 +0200 Subject: [PATCH 07/13] Update test `Subscriber` --- assets/js/wpr-beacon.min.js | 3 +-- inc/Engine/Common/PerformanceHints/AJAX/Subscriber.php | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/assets/js/wpr-beacon.min.js b/assets/js/wpr-beacon.min.js index 95da3a2107..cb58c6a0c7 100644 --- a/assets/js/wpr-beacon.min.js +++ b/assets/js/wpr-beacon.min.js @@ -1,2 +1 @@ -!function n(r,s,o){function a(t,e){if(!s[t]){if(!r[t]){var i="function"==typeof require&&require;if(!e&&i)return i(t,!0);if(c)return c(t,!0);throw(e=new Error("Cannot find module '"+t+"'")).code="MODULE_NOT_FOUND",e}i=s[t]={exports:{}},r[t][0].call(i.exports,function(e){return a(r[t][1][e]||e)},i,i.exports,n,r,s,o)}return s[t].exports}for(var c="function"==typeof require&&require,e=0;e{this._handleInfiniteLoop()},1e4),(await this._isGeneratedBefore()).lcp||(this.lcpBeacon=new r(this.config),await this.lcpBeacon.run()),this._saveFinalResultIntoDB()):this._finalize()}async _isValidPreconditions(){return this._isNotValidScreensize()?(this._logMessage("Bailing out because screen size is not acceptable"),!1):!this._isPageCached()||!await this._isGeneratedBefore()||(this._logMessage("Bailing out because data is already available"),!1)}_isPageCached(){var e=document.documentElement.nextSibling&&document.documentElement.nextSibling.data?document.documentElement.nextSibling.data:"";return e&&e.includes("Debug: cached")}async _isGeneratedBefore(){var e=new FormData,e=(e.append("action","rocket_check_beacon"),e.append("rocket_beacon_nonce",this.config.nonce),e.append("url",this.config.url),e.append("is_mobile",this.config.is_mobile),await fetch(this.config.ajax_url,{method:"POST",credentials:"same-origin",body:e}).then(e=>e.json()));return e.data}_isNotValidScreensize(){var e=window.innerWidth||document.documentElement.clientWidth,t=window.innerHeight||document.documentElement.clientHeight,i=this.config.is_mobile&&(e>this.config.width_threshold||t>this.config.height_threshold),e=!this.config.is_mobile&&(ee.json()).then(e=>{this._logMessage(e)}).catch(e=>{this._logMessage(e)}).finally(()=>{this._finalize()})}_getFinalStatus(){return""!==this.errorCode?this.errorCode:10<=(new Date-this.scriptTimer)/1e3?"timeout":"success"}_handleInfiniteLoop(){this._saveFinalResultIntoDB()}_finalize(){document.querySelector('[data-name="wpr-wpr-beacon"]').setAttribute("beacon-completed","true"),clearTimeout(this.infiniteLoopId)}_logMessage(e){this.config.debug&&console.log(e)}static run(){if(window.rocket_beacon_data){let e=new n(window.rocket_beacon_data);"loading"!==document.readyState?setTimeout(()=>{e.init()},window.rocket_beacon_data.delay):document.addEventListener("DOMContentLoaded",()=>{setTimeout(()=>{e.init()},window.rocket_beacon_data.delay)})}}}class r{constructor(e){this.config=e,this.performanceImages=[],this.errorCode=""}async run(){try{var e=this._generateLcpCandidates(1/0);e&&(this._initWithFirstElementWithInfo(e),this._fillATFWithoutDuplications(e))}catch(e){this.errorCode="script_error",this._logMessage("Script Error: "+e)}}_generateLcpCandidates(e){var t=document.querySelectorAll(this.config.elements);return t.length<=0?[]:Array.from(t).map(e=>{if("img"===e.nodeName.toLowerCase()&&"picture"===e.parentElement.nodeName.toLowerCase())return null;let t;if("picture"===e.nodeName.toLowerCase()){var i=e.querySelector("img");if(!i)return null;t=i.getBoundingClientRect()}else t=e.getBoundingClientRect();return{element:e,rect:t}}).filter(e=>null!==e).filter(e=>0({item:e,area:this._getElementArea(e.rect),elementInfo:this._getElementInfo(e.element)})).sort((e,t)=>t.area-e.area).slice(0,e).map(e=>({element:e.item.element,elementInfo:e.elementInfo}))}_getElementArea(e){return Math.min(e.width,(window.innerWidth||document.documentElement.clientWidth)-e.left)*Math.min(e.height,(window.innerHeight||document.documentElement.clientHeight)-e.top)}_getElementInfo(e){var t=e.nodeName.toLowerCase(),i={type:"",src:"",srcset:"",sizes:"",sources:[],bg_set:[],current_src:""};if("img"===t&&e.srcset)i.type="img-srcset",i.src=e.src,i.srcset=e.srcset,i.sizes=e.sizes,i.current_src=e.currentSrc;else if("img"===t)i.type="img",i.src=e.src,i.current_src=e.currentSrc;else if("video"===t){i.type="img";var n=e.querySelector("source");i.src=e.poster||(n?n.src:""),i.current_src=i.src}else if("svg"===t){n=e.querySelector("image");n&&(i.type="img",i.src=n.getAttribute("href")||"",i.current_src=i.src)}else if("picture"===t){i.type="picture";n=e.querySelector("img");i.src=n?n.src:"",i.sources=Array.from(e.querySelectorAll("source")).map(e=>({srcset:e.srcset||"",media:e.media||"",type:e.type||"",sizes:e.sizes||""}))}else{t=[window.getComputedStyle(e,null).getPropertyValue("background-image"),getComputedStyle(e,":after").getPropertyValue("background-image"),getComputedStyle(e,":before").getPropertyValue("background-image")].filter(e=>"none"!==e);if(0===t.length)return null;n=t[0];if(i.type="bg-img",n.includes("image-set(")&&(i.type="bg-img-set"),!n||""===n||n.includes("data:image"))return null;e=[...n.matchAll(/url\(\s*?['"]?\s*?(.+?)\s*?["']?\s*?\)/gi)];i.bg_set=e.map(e=>e[1]?{src:e[1].trim()+(e[2]?" "+e[2].trim():"")}:{}),i.bg_set.every(e=>""===e.src)&&(i.bg_set=e.map(e=>e[1]?{src:e[1].trim()}:{})),0null!==e.elementInfo);e?this.performanceImages=[{...e.elementInfo,label:"lcp"}]:(this._logMessage("No LCP candidate found."),this.performanceImages=[])}_fillATFWithoutDuplications(e){e.forEach(e=>{var{element:e,elementInfo:t}=e;!this._isDuplicateImage(e)&&t&&this.performanceImages.push({...t,label:"above-the-fold"})})}_isDuplicateImage(e){let t=this._getElementInfo(e);var i;return null!==t&&(e="img"===t.type||"img-srcset"===t.type||"video"===t.type,i="bg-img"===t.type||"bg-img-set"===t.type||"picture"===t.type,e||i)&&this.performanceImages.some(e=>e.src===t.src)}_logMessage(e){this.config.debug&&console.log(e)}getResults(){return this.performanceImages}}n.run()},{}]},{},[1]); -//# sourceMappingURL=wpr-beacon.min.js.map +class RocketBeacon{constructor(e){this.config=e,this.lcpBeacon=null,this.infiniteLoopId=null,this.scriptTimer=new Date,this.errorCode=""}async init(){if(!await this._isValidPreconditions()){this._finalize();return}this.infiniteLoopId=setTimeout(()=>{this._handleInfiniteLoop()},1e4);let e=await this._isGeneratedBefore();e.lcp||(this.lcpBeacon=new RocketLcpBeacon(this.config),await this.lcpBeacon.run()),this._saveFinalResultIntoDB()}async _isValidPreconditions(){return this._isNotValidScreensize()?(this._logMessage("Bailing out because screen size is not acceptable"),!1):!(this._isPageCached()&&await this._isGeneratedBefore())||(this._logMessage("Bailing out because data is already available"),!1)}_isPageCached(){let e=document.documentElement.nextSibling&&document.documentElement.nextSibling.data?document.documentElement.nextSibling.data:"";return e&&e.includes("Debug: cached")}async _isGeneratedBefore(){let e=new FormData;e.append("action","rocket_check_beacon"),e.append("rocket_beacon_nonce",this.config.nonce),e.append("url",this.config.url),e.append("is_mobile",this.config.is_mobile);let t=await fetch(this.config.ajax_url,{method:"POST",credentials:"same-origin",body:e}).then(e=>e.json());return t.data}_isNotValidScreensize(){let e=window.innerWidth||document.documentElement.clientWidth,t=window.innerHeight||document.documentElement.clientHeight,i=this.config.is_mobile&&(e>this.config.width_threshold||t>this.config.height_threshold),n=!this.config.is_mobile&&(e=0&&e.right>=0&&e.top<=(window.innerHeight||document.documentElement.clientHeight)&&e.left<=(window.innerWidth||document.documentElement.clientWidth)}_saveFinalResultIntoDB(){let e=this.lcpBeacon?this.lcpBeacon.getResults():null,t=new FormData;t.append("action","rocket_beacon"),t.append("rocket_beacon_nonce",this.config.nonce),t.append("url",this.config.url),t.append("is_mobile",this.config.is_mobile),t.append("status",this._getFinalStatus()),t.append("lcp_images",JSON.stringify(e)),fetch(this.config.ajax_url,{method:"POST",credentials:"same-origin",body:t,headers:{"wpr-saas-no-intercept":!0}}).then(e=>e.json()).then(e=>{this._logMessage(e)}).catch(e=>{this._logMessage(e)}).finally(()=>{this._finalize()})}_getFinalStatus(){if(""!==this.errorCode)return this.errorCode;let e=(new Date-this.scriptTimer)/1e3;return 10<=e?"timeout":"success"}_handleInfiniteLoop(){this._saveFinalResultIntoDB()}_finalize(){let e=document.querySelector('[data-name="wpr-wpr-beacon"]');e.setAttribute("beacon-completed","true"),clearTimeout(this.infiniteLoopId)}_logMessage(e){this.config.debug&&console.log(e)}static run(){if(!window.rocket_beacon_data)return;let e=new RocketBeacon(window.rocket_beacon_data);if("loading"!==document.readyState){setTimeout(()=>{e.init()},window.rocket_beacon_data.delay);return}document.addEventListener("DOMContentLoaded",()=>{setTimeout(()=>{e.init()},window.rocket_beacon_data.delay)})}}class RocketLcpBeacon{constructor(e){this.config=e,this.performanceImages=[],this.errorCode=""}async run(){try{let e=this._generateLcpCandidates(1/0);e&&(this._initWithFirstElementWithInfo(e),this._fillATFWithoutDuplications(e))}catch(t){this.errorCode="script_error",this._logMessage("Script Error: "+t)}}_generateLcpCandidates(e){let t=document.querySelectorAll(this.config.elements);if(t.length<=0)return[];let i=Array.from(t),n=i.map(e=>{if("img"===e.nodeName.toLowerCase()&&"picture"===e.parentElement.nodeName.toLowerCase())return null;let t;if("picture"===e.nodeName.toLowerCase()){let i=e.querySelector("img");if(!i)return null;t=i.getBoundingClientRect()}else t=e.getBoundingClientRect();return{element:e,rect:t}}).filter(e=>null!==e).filter(e=>e.rect.width>0&&e.rect.height>0&&RocketBeacon._isIntersecting(e.rect)).map(e=>({item:e,area:this._getElementArea(e.rect),elementInfo:this._getElementInfo(e.element)})).sort((e,t)=>t.area-e.area).slice(0,e);return n.map(e=>({element:e.item.element,elementInfo:e.elementInfo}))}_getElementArea(e){let t=Math.min(e.width,(window.innerWidth||document.documentElement.clientWidth)-e.left),i=Math.min(e.height,(window.innerHeight||document.documentElement.clientHeight)-e.top);return t*i}_getElementInfo(e){let t=e.nodeName.toLowerCase(),i={type:"",src:"",srcset:"",sizes:"",sources:[],bg_set:[],current_src:""};if("img"===t&&e.srcset)i.type="img-srcset",i.src=e.src,i.srcset=e.srcset,i.sizes=e.sizes,i.current_src=e.currentSrc;else if("img"===t)i.type="img",i.src=e.src,i.current_src=e.currentSrc;else if("video"===t){i.type="img";let n=e.querySelector("source");i.src=e.poster||(n?n.src:""),i.current_src=i.src}else if("svg"===t){let s=e.querySelector("image");s&&(i.type="img",i.src=s.getAttribute("href")||"",i.current_src=i.src)}else if("picture"===t){i.type="picture";let r=e.querySelector("img");i.src=r?r.src:"",i.sources=Array.from(e.querySelectorAll("source")).map(e=>({srcset:e.srcset||"",media:e.media||"",type:e.type||"",sizes:e.sizes||""}))}else{let c=window.getComputedStyle(e,null),o=[c.getPropertyValue("background-image"),getComputedStyle(e,":after").getPropertyValue("background-image"),getComputedStyle(e,":before").getPropertyValue("background-image")].filter(e=>"none"!==e);if(0===o.length)return null;let a=o[0];if(i.type="bg-img",a.includes("image-set(")&&(i.type="bg-img-set"),!a||""===a||a.includes("data:image"))return null;let l=[...a.matchAll(/url\(\s*?['"]?\s*?(.+?)\s*?["']?\s*?\)/ig)];i.bg_set=l.map(e=>e[1]?{src:e[1].trim()+(e[2]?" "+e[2].trim():"")}:{}),i.bg_set.every(e=>""===e.src)&&(i.bg_set=l.map(e=>e[1]?{src:e[1].trim()}:{})),i.bg_set.length>0&&(i.src=i.bg_set[0].src,"bg-img-set"===i.type&&(i.src=i.bg_set))}return i}_initWithFirstElementWithInfo(e){let t=e.find(e=>null!==e.elementInfo);if(!t){this._logMessage("No LCP candidate found."),this.performanceImages=[];return}this.performanceImages=[{...t.elementInfo,label:"lcp"}]}_fillATFWithoutDuplications(e){e.forEach(({element:e,elementInfo:t})=>{!this._isDuplicateImage(e)&&t&&this.performanceImages.push({...t,label:"above-the-fold"})})}_isDuplicateImage(e){let t=this._getElementInfo(e);if(null===t)return!1;let i="img"===t.type||"img-srcset"===t.type||"video"===t.type,n="bg-img"===t.type||"bg-img-set"===t.type||"picture"===t.type;return(i||n)&&this.performanceImages.some(e=>e.src===t.src)}_logMessage(e){this.config.debug&&console.log(e)}getResults(){return this.performanceImages}}RocketBeacon.run(); \ No newline at end of file diff --git a/inc/Engine/Common/PerformanceHints/AJAX/Subscriber.php b/inc/Engine/Common/PerformanceHints/AJAX/Subscriber.php index ec935fbf1a..ef26dc446c 100644 --- a/inc/Engine/Common/PerformanceHints/AJAX/Subscriber.php +++ b/inc/Engine/Common/PerformanceHints/AJAX/Subscriber.php @@ -31,10 +31,10 @@ public function __construct( array $factories ) { */ public static function get_subscribed_events(): array { return [ - 'wp_ajax_rocket_lcp' => 'add_data', - 'wp_ajax_nopriv_rocket_lcp' => 'add_data', - 'wp_ajax_rocket_check_lcp' => 'check_data', - 'wp_ajax_nopriv_rocket_check_lcp' => 'check_data', + 'wp_ajax_rocket_beacon' => 'add_data', + 'wp_ajax_nopriv_rocket_beacon' => 'add_data', + 'wp_ajax_rocket_check_beacon' => 'check_data', + 'wp_ajax_nopriv_rocket_check_beacon' => 'check_data', ]; } From 3d52940643e64da7efa9955d1ecb01386fdde368 Mon Sep 17 00:00:00 2001 From: Gael Robin Date: Tue, 23 Jul 2024 04:52:45 +0200 Subject: [PATCH 08/13] Update test beacon injection --- inc/Engine/Common/PerformanceHints/Frontend/Processor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/Engine/Common/PerformanceHints/Frontend/Processor.php b/inc/Engine/Common/PerformanceHints/Frontend/Processor.php index 1a3dd065e6..c8ea64940d 100644 --- a/inc/Engine/Common/PerformanceHints/Frontend/Processor.php +++ b/inc/Engine/Common/PerformanceHints/Frontend/Processor.php @@ -111,7 +111,7 @@ public function maybe_apply_optimizations( string $html ): string { private function inject_beacon( $html, $url, $is_mobile ): string { $min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; - if ( ! $this->filesystem->exists( rocket_get_constant( 'WP_ROCKET_ASSETS_JS_PATH' ) . 'lcp-beacon' . $min . '.js' ) ) { + if ( ! $this->filesystem->exists( rocket_get_constant( 'WP_ROCKET_ASSETS_JS_PATH' ) . 'wpr-beacon' . $min . '.js' ) ) { return $html; } From 932677e187be26d61f4d61e235f0497b3daa578f Mon Sep 17 00:00:00 2001 From: WordPressFan Date: Tue, 23 Jul 2024 10:15:09 +0300 Subject: [PATCH 09/13] update beacon script --- README.md | 1 + assets/js/wpr-beacon.js | 701 ++++++++++++++------------------ assets/js/wpr-beacon.min.js | 3 +- assets/js/wpr-beacon.min.js.map | 8 +- gulpfile.js | 2 +- package-lock.json | 321 +++++++-------- package.json | 2 +- 7 files changed, 468 insertions(+), 570 deletions(-) diff --git a/README.md b/README.md index a5b8806895..ba8d5bf40a 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ To be able to validate your license and use the plugin, you will also have to ma | `gulp build:js:lazyloadcss:min` | Builds lazyload CSS js file, the minified version (lazyload-css.min.js) | | `gulp build:js:lcp` | Builds lcp beacon script, the minified version (lcp-beacon.min.js, source file, and map file) | | `gulp build:js:all` | Builds all js files mentioned above (wpr-admin.js, wpr-admin.min.js, lazyload-css.min.js, lcp-beacon) | +| `gulp build:js:lcp` | Builds lcp beacon script, the minified version (wpr-beacon.min.js, source file, and map file) | | `gulp js:watch` | Watches all js files changes and build them again with any change. | diff --git a/assets/js/wpr-beacon.js b/assets/js/wpr-beacon.js index a24e9b45eb..b503459d0d 100644 --- a/assets/js/wpr-beacon.js +++ b/assets/js/wpr-beacon.js @@ -1,390 +1,311 @@ -class RocketBeacon { - constructor(config) { - this.config = config; - this.lcpBeacon = null; - this.infiniteLoopId = null; - this.scriptTimer = new Date(); - this.errorCode = ''; - } - - async init() { - if (!await this._isValidPreconditions()) { - this._finalize(); - return; - } - - this.infiniteLoopId = setTimeout(() => { - this._handleInfiniteLoop(); - }, 10000); - - const isGeneratedBefore = await this._isGeneratedBefore(); - - if (!isGeneratedBefore.lcp) { - this.lcpBeacon = new RocketLcpBeacon(this.config); - await this.lcpBeacon.run(); - } - - this._saveFinalResultIntoDB(); - } - - async _isValidPreconditions() { - if (this._isNotValidScreensize()) { - this._logMessage('Bailing out because screen size is not acceptable'); - return false; - } - - if (this._isPageCached() && await this._isGeneratedBefore()) { - this._logMessage('Bailing out because data is already available'); - return false; - } - - return true; - } - - _isPageCached() { - const signature = document.documentElement.nextSibling && document.documentElement.nextSibling.data ? document.documentElement.nextSibling.data : ''; - return signature && signature.includes('Debug: cached'); - } - - async _isGeneratedBefore() { - let data_check = new FormData(); - data_check.append('action', 'rocket_check_beacon'); - data_check.append('rocket_beacon_nonce', this.config.nonce); - data_check.append('url', this.config.url); - data_check.append('is_mobile', this.config.is_mobile); - - const beacon_data_response = await fetch(this.config.ajax_url, { - method: "POST", - credentials: 'same-origin', - body: data_check - }).then(data => data.json()); - - return beacon_data_response.data; - } - - _isNotValidScreensize() { - const screenWidth = window.innerWidth || document.documentElement.clientWidth; - const screenHeight = window.innerHeight || document.documentElement.clientHeight; - - const isNotValidForMobile = this.config.is_mobile && - (screenWidth > this.config.width_threshold || screenHeight > this.config.height_threshold); - const isNotValidForDesktop = !this.config.is_mobile && - (screenWidth < this.config.width_threshold || screenHeight < this.config.height_threshold); - - return isNotValidForMobile || isNotValidForDesktop; - } - - static _isIntersecting(rect) { - return ( - rect.bottom >= 0 && - rect.right >= 0 && - rect.top <= (window.innerHeight || document.documentElement.clientHeight) && - rect.left <= (window.innerWidth || document.documentElement.clientWidth) - ); - } - - _saveFinalResultIntoDB() { - const lcpResults = this.lcpBeacon ? this.lcpBeacon.getResults() : null; - - const data = new FormData(); - data.append('action', 'rocket_beacon'); - data.append('rocket_beacon_nonce', this.config.nonce); - data.append('url', this.config.url); - data.append('is_mobile', this.config.is_mobile); - data.append('status', this._getFinalStatus()); - data.append('lcp_images', JSON.stringify(lcpResults)); - - fetch(this.config.ajax_url, { - method: "POST", - credentials: 'same-origin', - body: data, - headers: { - 'wpr-saas-no-intercept': true - } - }) - .then(response => response.json()) - .then(data => { - this._logMessage(data); - }) - .catch(error => { - this._logMessage(error); - }) - .finally(() => { - this._finalize(); - }); - } - - _getFinalStatus() { - if ('' !== this.errorCode) { - return this.errorCode; - } - - const scriptTime = (new Date() - this.scriptTimer) / 1000; - if (10 <= scriptTime) { - return 'timeout'; - } - - return 'success'; - } - - _handleInfiniteLoop() { - this._saveFinalResultIntoDB(); - } - - _finalize() { - const beaconscript = document.querySelector('[data-name="wpr-wpr-beacon"]'); - beaconscript.setAttribute('beacon-completed', 'true'); - clearTimeout(this.infiniteLoopId); - } - - _logMessage(msg) { - if (!this.config.debug) { - return; - } - console.log(msg); - } - - static run() { - if (!window.rocket_beacon_data) { - return; - } - - const instance = new RocketBeacon(window.rocket_beacon_data); - - if (document.readyState !== 'loading') { - setTimeout(() => { - instance.init(); - }, window.rocket_beacon_data.delay); - return; - } - - document.addEventListener("DOMContentLoaded", () => { - setTimeout(() => { - instance.init(); - }, window.rocket_beacon_data.delay); - }); - } -} - - -class RocketLcpBeacon { - constructor(config) { - this.config = config; - this.performanceImages = []; - this.errorCode = ''; - } - - async run() { - try { - const above_the_fold_images = this._generateLcpCandidates(Infinity); - if (above_the_fold_images) { - this._initWithFirstElementWithInfo(above_the_fold_images); - this._fillATFWithoutDuplications(above_the_fold_images); - } - } catch (err) { - this.errorCode = 'script_error'; - this._logMessage('Script Error: ' + err); - } - } - - _generateLcpCandidates(count) { - const lcpElements = document.querySelectorAll(this.config.elements); - - if (lcpElements.length <= 0) { - return []; - } - - const potentialCandidates = Array.from(lcpElements); - - const topCandidates = potentialCandidates.map(element => { - if ('img' === element.nodeName.toLowerCase() && 'picture' === element.parentElement.nodeName.toLowerCase()) { - return null; - } - let rect; - if ('picture' === element.nodeName.toLowerCase()) { - const imgElement = element.querySelector('img'); - if (imgElement) { - rect = imgElement.getBoundingClientRect(); - } else { - return null; - } - } else { - rect = element.getBoundingClientRect(); - } - - return { - element: element, - rect: rect, - }; - }) - .filter(item => item !== null) - .filter(item => { - return ( - item.rect.width > 0 && - item.rect.height > 0 && - RocketBeacon._isIntersecting(item.rect) - ); - }) - .map(item => ({ - item, - area: this._getElementArea(item.rect), - elementInfo: this._getElementInfo(item.element), - })) - .sort((a, b) => b.area - a.area) - .slice(0, count); - - return topCandidates.map(candidate => ({ - element: candidate.item.element, - elementInfo: candidate.elementInfo, - })); - } - - _getElementArea(rect) { - const visibleWidth = Math.min(rect.width, (window.innerWidth || document.documentElement.clientWidth) - rect.left); - const visibleHeight = Math.min(rect.height, (window.innerHeight || document.documentElement.clientHeight) - rect.top); - - return visibleWidth * visibleHeight; - } - - _getElementInfo(element) { - const nodeName = element.nodeName.toLowerCase(); - const element_info = { - type: "", - src: "", - srcset: "", - sizes: "", - sources: [], - bg_set: [], - current_src: "" - }; - - const css_bg_url_rgx = /url\(\s*?['"]?\s*?(.+?)\s*?["']?\s*?\)/ig; - - if (nodeName === "img" && element.srcset) { - element_info.type = "img-srcset"; - element_info.src = element.src; - element_info.srcset = element.srcset; - element_info.sizes = element.sizes; - element_info.current_src = element.currentSrc; - } else if (nodeName === "img") { - element_info.type = "img"; - element_info.src = element.src; - element_info.current_src = element.currentSrc; - } else if (nodeName === "video") { - element_info.type = "img"; - const source = element.querySelector('source'); - element_info.src = element.poster || (source ? source.src : ''); - element_info.current_src = element_info.src; - } else if (nodeName === "svg") { - const imageElement = element.querySelector('image'); - if (imageElement) { - element_info.type = "img"; - element_info.src = imageElement.getAttribute('href') || ''; - element_info.current_src = element_info.src; - } - } else if (nodeName === "picture") { - element_info.type = "picture"; - const img = element.querySelector('img'); - element_info.src = img ? img.src : ""; - element_info.sources = Array.from(element.querySelectorAll('source')).map(source => ({ - srcset: source.srcset || '', - media: source.media || '', - type: source.type || '', - sizes: source.sizes || '' - })); - } else { - const computed_style = window.getComputedStyle(element, null); - const bg_props = [ - computed_style.getPropertyValue("background-image"), - getComputedStyle(element, ":after").getPropertyValue("background-image"), - getComputedStyle(element, ":before").getPropertyValue("background-image") - ].filter(prop => prop !== "none"); - - if (bg_props.length === 0) { - return null; - } - const full_bg_prop = bg_props[0]; - element_info.type = "bg-img"; - if (full_bg_prop.includes("image-set(")) { - element_info.type = "bg-img-set"; - } - if (!full_bg_prop || full_bg_prop === "" || full_bg_prop.includes('data:image')) { - return null; - } - - const matches = [...full_bg_prop.matchAll(css_bg_url_rgx)]; - element_info.bg_set = matches.map(m => m[1] ? { src: m[1].trim() + (m[2] ? " " + m[2].trim() : "") } : {}); - if (element_info.bg_set.every(item => item.src === "")) { - element_info.bg_set = matches.map(m => m[1] ? { src: m[1].trim() } : {}); - } - - if (element_info.bg_set.length > 0) { - element_info.src = element_info.bg_set[0].src; - if (element_info.type === "bg-img-set") { - element_info.src = element_info.bg_set; - } - } - } - - return element_info; - } - - _initWithFirstElementWithInfo(elements) { - const firstElementWithInfo = elements.find(item => item.elementInfo !== null); - - if (!firstElementWithInfo) { - this._logMessage("No LCP candidate found."); - this.performanceImages = []; - return; - } - - this.performanceImages = [{ - ...firstElementWithInfo.elementInfo, - label: "lcp", - }]; - } - - _fillATFWithoutDuplications(elements) { - elements.forEach(({ element, elementInfo }) => { - if (this._isDuplicateImage(element) || !elementInfo) { - return; - } - - this.performanceImages.push({ ...elementInfo, label: "above-the-fold" }); - }); - } - - _isDuplicateImage(image) { - const elementInfo = this._getElementInfo(image); - - if (elementInfo === null) { - return false; - } - - const isImageOrVideo = - elementInfo.type === "img" || - elementInfo.type === "img-srcset" || - elementInfo.type === "video"; - - const isBgImageOrPicture = - elementInfo.type === "bg-img" || - elementInfo.type === "bg-img-set" || - elementInfo.type === "picture"; - - return (isImageOrVideo || isBgImageOrPicture) && - this.performanceImages.some(item => item.src === elementInfo.src); - } - - _logMessage(msg) { - if (!this.config.debug) { - return; - } - console.log(msg); - } - - getResults() { - return this.performanceImages; - } -} - -RocketBeacon.run(); \ No newline at end of file +(() => { + // src/RocketLcpBeacon.js + var RocketLcpBeacon = class { + constructor(config) { + this.config = config; + this.performanceImages = []; + this.errorCode = ""; + } + async run() { + try { + const above_the_fold_images = this._generateLcpCandidates(Infinity); + if (above_the_fold_images) { + this._initWithFirstElementWithInfo(above_the_fold_images); + this._fillATFWithoutDuplications(above_the_fold_images); + } + } catch (err) { + this.errorCode = "script_error"; + this._logMessage("Script Error: " + err); + } + } + _generateLcpCandidates(count) { + const lcpElements = document.querySelectorAll(this.config.elements); + if (lcpElements.length <= 0) { + return []; + } + const potentialCandidates = Array.from(lcpElements); + const topCandidates = potentialCandidates.map((element) => { + if ("img" === element.nodeName.toLowerCase() && "picture" === element.parentElement.nodeName.toLowerCase()) { + return null; + } + let rect; + if ("picture" === element.nodeName.toLowerCase()) { + const imgElement = element.querySelector("img"); + if (imgElement) { + rect = imgElement.getBoundingClientRect(); + } else { + return null; + } + } else { + rect = element.getBoundingClientRect(); + } + return { + element, + rect + }; + }).filter((item) => item !== null).filter((item) => { + return item.rect.width > 0 && item.rect.height > 0 && RocketBeacon._isIntersecting(item.rect); + }).map((item) => ({ + item, + area: this._getElementArea(item.rect), + elementInfo: this._getElementInfo(item.element) + })).sort((a, b) => b.area - a.area).slice(0, count); + return topCandidates.map((candidate) => ({ + element: candidate.item.element, + elementInfo: candidate.elementInfo + })); + } + _getElementArea(rect) { + const visibleWidth = Math.min(rect.width, (window.innerWidth || document.documentElement.clientWidth) - rect.left); + const visibleHeight = Math.min(rect.height, (window.innerHeight || document.documentElement.clientHeight) - rect.top); + return visibleWidth * visibleHeight; + } + _getElementInfo(element) { + const nodeName = element.nodeName.toLowerCase(); + const element_info = { + type: "", + src: "", + srcset: "", + sizes: "", + sources: [], + bg_set: [], + current_src: "" + }; + const css_bg_url_rgx = /url\(\s*?['"]?\s*?(.+?)\s*?["']?\s*?\)/ig; + if (nodeName === "img" && element.srcset) { + element_info.type = "img-srcset"; + element_info.src = element.src; + element_info.srcset = element.srcset; + element_info.sizes = element.sizes; + element_info.current_src = element.currentSrc; + } else if (nodeName === "img") { + element_info.type = "img"; + element_info.src = element.src; + element_info.current_src = element.currentSrc; + } else if (nodeName === "video") { + element_info.type = "img"; + const source = element.querySelector("source"); + element_info.src = element.poster || (source ? source.src : ""); + element_info.current_src = element_info.src; + } else if (nodeName === "svg") { + const imageElement = element.querySelector("image"); + if (imageElement) { + element_info.type = "img"; + element_info.src = imageElement.getAttribute("href") || ""; + element_info.current_src = element_info.src; + } + } else if (nodeName === "picture") { + element_info.type = "picture"; + const img = element.querySelector("img"); + element_info.src = img ? img.src : ""; + element_info.sources = Array.from(element.querySelectorAll("source")).map((source) => ({ + srcset: source.srcset || "", + media: source.media || "", + type: source.type || "", + sizes: source.sizes || "" + })); + } else { + const computed_style = window.getComputedStyle(element, null); + const bg_props = [ + computed_style.getPropertyValue("background-image"), + getComputedStyle(element, ":after").getPropertyValue("background-image"), + getComputedStyle(element, ":before").getPropertyValue("background-image") + ].filter((prop) => prop !== "none"); + if (bg_props.length === 0) { + return null; + } + const full_bg_prop = bg_props[0]; + element_info.type = "bg-img"; + if (full_bg_prop.includes("image-set(")) { + element_info.type = "bg-img-set"; + } + if (!full_bg_prop || full_bg_prop === "" || full_bg_prop.includes("data:image")) { + return null; + } + const matches = [...full_bg_prop.matchAll(css_bg_url_rgx)]; + element_info.bg_set = matches.map((m) => m[1] ? { src: m[1].trim() + (m[2] ? " " + m[2].trim() : "") } : {}); + if (element_info.bg_set.every((item) => item.src === "")) { + element_info.bg_set = matches.map((m) => m[1] ? { src: m[1].trim() } : {}); + } + if (element_info.bg_set.length > 0) { + element_info.src = element_info.bg_set[0].src; + if (element_info.type === "bg-img-set") { + element_info.src = element_info.bg_set; + } + } + } + return element_info; + } + _initWithFirstElementWithInfo(elements) { + const firstElementWithInfo = elements.find((item) => item.elementInfo !== null); + if (!firstElementWithInfo) { + this._logMessage("No LCP candidate found."); + this.performanceImages = []; + return; + } + this.performanceImages = [{ + ...firstElementWithInfo.elementInfo, + label: "lcp" + }]; + } + _fillATFWithoutDuplications(elements) { + elements.forEach(({ element, elementInfo }) => { + if (this._isDuplicateImage(element) || !elementInfo) { + return; + } + this.performanceImages.push({ ...elementInfo, label: "above-the-fold" }); + }); + } + _isDuplicateImage(image) { + const elementInfo = this._getElementInfo(image); + if (elementInfo === null) { + return false; + } + const isImageOrVideo = elementInfo.type === "img" || elementInfo.type === "img-srcset" || elementInfo.type === "video"; + const isBgImageOrPicture = elementInfo.type === "bg-img" || elementInfo.type === "bg-img-set" || elementInfo.type === "picture"; + return (isImageOrVideo || isBgImageOrPicture) && this.performanceImages.some((item) => item.src === elementInfo.src); + } + _logMessage(msg) { + if (!this.config.debug) { + return; + } + console.log(msg); + } + getResults() { + return this.performanceImages; + } + }; + var RocketLcpBeacon_default = RocketLcpBeacon; + + // src/RocketBeacon.js + var RocketBeacon2 = class { + constructor(config) { + this.config = config; + this.lcpBeacon = null; + this.infiniteLoopId = null; + this.scriptTimer = /* @__PURE__ */ new Date(); + this.errorCode = ""; + } + async init() { + if (!await this._isValidPreconditions()) { + this._finalize(); + return; + } + this.infiniteLoopId = setTimeout(() => { + this._handleInfiniteLoop(); + }, 1e4); + const isGeneratedBefore = await this._isGeneratedBefore(); + if (!isGeneratedBefore.lcp) { + this.lcpBeacon = new RocketLcpBeacon_default(this.config); + await this.lcpBeacon.run(); + } + this._saveFinalResultIntoDB(); + } + async _isValidPreconditions() { + if (this._isNotValidScreensize()) { + this._logMessage("Bailing out because screen size is not acceptable"); + return false; + } + if (this._isPageCached() && await this._isGeneratedBefore()) { + this._logMessage("Bailing out because data is already available"); + return false; + } + return true; + } + _isPageCached() { + const signature = document.documentElement.nextSibling && document.documentElement.nextSibling.data ? document.documentElement.nextSibling.data : ""; + return signature && signature.includes("Debug: cached"); + } + async _isGeneratedBefore() { + let data_check = new FormData(); + data_check.append("action", "rocket_check_beacon"); + data_check.append("rocket_beacon_nonce", this.config.nonce); + data_check.append("url", this.config.url); + data_check.append("is_mobile", this.config.is_mobile); + const beacon_data_response = await fetch(this.config.ajax_url, { + method: "POST", + credentials: "same-origin", + body: data_check + }).then((data) => data.json()); + return beacon_data_response.data; + } + _isNotValidScreensize() { + const screenWidth = window.innerWidth || document.documentElement.clientWidth; + const screenHeight = window.innerHeight || document.documentElement.clientHeight; + const isNotValidForMobile = this.config.is_mobile && (screenWidth > this.config.width_threshold || screenHeight > this.config.height_threshold); + const isNotValidForDesktop = !this.config.is_mobile && (screenWidth < this.config.width_threshold || screenHeight < this.config.height_threshold); + return isNotValidForMobile || isNotValidForDesktop; + } + static _isIntersecting(rect) { + return rect.bottom >= 0 && rect.right >= 0 && rect.top <= (window.innerHeight || document.documentElement.clientHeight) && rect.left <= (window.innerWidth || document.documentElement.clientWidth); + } + _saveFinalResultIntoDB() { + const lcpResults = this.lcpBeacon ? this.lcpBeacon.getResults() : null; + const data = new FormData(); + data.append("action", "rocket_beacon"); + data.append("rocket_beacon_nonce", this.config.nonce); + data.append("url", this.config.url); + data.append("is_mobile", this.config.is_mobile); + data.append("status", this._getFinalStatus()); + data.append("lcp_images", JSON.stringify(lcpResults)); + fetch(this.config.ajax_url, { + method: "POST", + credentials: "same-origin", + body: data, + headers: { + "wpr-saas-no-intercept": true + } + }).then((response) => response.json()).then((data2) => { + this._logMessage(data2); + }).catch((error) => { + this._logMessage(error); + }).finally(() => { + this._finalize(); + }); + } + _getFinalStatus() { + if ("" !== this.errorCode) { + return this.errorCode; + } + const scriptTime = (/* @__PURE__ */ new Date() - this.scriptTimer) / 1e3; + if (10 <= scriptTime) { + return "timeout"; + } + return "success"; + } + _handleInfiniteLoop() { + this._saveFinalResultIntoDB(); + } + _finalize() { + const beaconscript = document.querySelector('[data-name="wpr-wpr-beacon"]'); + beaconscript.setAttribute("beacon-completed", "true"); + clearTimeout(this.infiniteLoopId); + } + _logMessage(msg) { + if (!this.config.debug) { + return; + } + console.log(msg); + } + }; + var RocketBeacon_default = RocketBeacon2; + + // src/RocketFinalBeacon.js + ((rocket_beacon_data) => { + if (!rocket_beacon_data) { + return; + } + const instance = new RocketBeacon_default(rocket_beacon_data); + if (document.readyState !== "loading") { + setTimeout(() => { + instance.init(); + }, rocket_beacon_data.delay); + return; + } + document.addEventListener("DOMContentLoaded", () => { + setTimeout(() => { + instance.init(); + }, rocket_beacon_data.delay); + }); + })(window.rocket_beacon_data); +})(); diff --git a/assets/js/wpr-beacon.min.js b/assets/js/wpr-beacon.min.js index cb58c6a0c7..e9f16562eb 100644 --- a/assets/js/wpr-beacon.min.js +++ b/assets/js/wpr-beacon.min.js @@ -1 +1,2 @@ -class RocketBeacon{constructor(e){this.config=e,this.lcpBeacon=null,this.infiniteLoopId=null,this.scriptTimer=new Date,this.errorCode=""}async init(){if(!await this._isValidPreconditions()){this._finalize();return}this.infiniteLoopId=setTimeout(()=>{this._handleInfiniteLoop()},1e4);let e=await this._isGeneratedBefore();e.lcp||(this.lcpBeacon=new RocketLcpBeacon(this.config),await this.lcpBeacon.run()),this._saveFinalResultIntoDB()}async _isValidPreconditions(){return this._isNotValidScreensize()?(this._logMessage("Bailing out because screen size is not acceptable"),!1):!(this._isPageCached()&&await this._isGeneratedBefore())||(this._logMessage("Bailing out because data is already available"),!1)}_isPageCached(){let e=document.documentElement.nextSibling&&document.documentElement.nextSibling.data?document.documentElement.nextSibling.data:"";return e&&e.includes("Debug: cached")}async _isGeneratedBefore(){let e=new FormData;e.append("action","rocket_check_beacon"),e.append("rocket_beacon_nonce",this.config.nonce),e.append("url",this.config.url),e.append("is_mobile",this.config.is_mobile);let t=await fetch(this.config.ajax_url,{method:"POST",credentials:"same-origin",body:e}).then(e=>e.json());return t.data}_isNotValidScreensize(){let e=window.innerWidth||document.documentElement.clientWidth,t=window.innerHeight||document.documentElement.clientHeight,i=this.config.is_mobile&&(e>this.config.width_threshold||t>this.config.height_threshold),n=!this.config.is_mobile&&(e=0&&e.right>=0&&e.top<=(window.innerHeight||document.documentElement.clientHeight)&&e.left<=(window.innerWidth||document.documentElement.clientWidth)}_saveFinalResultIntoDB(){let e=this.lcpBeacon?this.lcpBeacon.getResults():null,t=new FormData;t.append("action","rocket_beacon"),t.append("rocket_beacon_nonce",this.config.nonce),t.append("url",this.config.url),t.append("is_mobile",this.config.is_mobile),t.append("status",this._getFinalStatus()),t.append("lcp_images",JSON.stringify(e)),fetch(this.config.ajax_url,{method:"POST",credentials:"same-origin",body:t,headers:{"wpr-saas-no-intercept":!0}}).then(e=>e.json()).then(e=>{this._logMessage(e)}).catch(e=>{this._logMessage(e)}).finally(()=>{this._finalize()})}_getFinalStatus(){if(""!==this.errorCode)return this.errorCode;let e=(new Date-this.scriptTimer)/1e3;return 10<=e?"timeout":"success"}_handleInfiniteLoop(){this._saveFinalResultIntoDB()}_finalize(){let e=document.querySelector('[data-name="wpr-wpr-beacon"]');e.setAttribute("beacon-completed","true"),clearTimeout(this.infiniteLoopId)}_logMessage(e){this.config.debug&&console.log(e)}static run(){if(!window.rocket_beacon_data)return;let e=new RocketBeacon(window.rocket_beacon_data);if("loading"!==document.readyState){setTimeout(()=>{e.init()},window.rocket_beacon_data.delay);return}document.addEventListener("DOMContentLoaded",()=>{setTimeout(()=>{e.init()},window.rocket_beacon_data.delay)})}}class RocketLcpBeacon{constructor(e){this.config=e,this.performanceImages=[],this.errorCode=""}async run(){try{let e=this._generateLcpCandidates(1/0);e&&(this._initWithFirstElementWithInfo(e),this._fillATFWithoutDuplications(e))}catch(t){this.errorCode="script_error",this._logMessage("Script Error: "+t)}}_generateLcpCandidates(e){let t=document.querySelectorAll(this.config.elements);if(t.length<=0)return[];let i=Array.from(t),n=i.map(e=>{if("img"===e.nodeName.toLowerCase()&&"picture"===e.parentElement.nodeName.toLowerCase())return null;let t;if("picture"===e.nodeName.toLowerCase()){let i=e.querySelector("img");if(!i)return null;t=i.getBoundingClientRect()}else t=e.getBoundingClientRect();return{element:e,rect:t}}).filter(e=>null!==e).filter(e=>e.rect.width>0&&e.rect.height>0&&RocketBeacon._isIntersecting(e.rect)).map(e=>({item:e,area:this._getElementArea(e.rect),elementInfo:this._getElementInfo(e.element)})).sort((e,t)=>t.area-e.area).slice(0,e);return n.map(e=>({element:e.item.element,elementInfo:e.elementInfo}))}_getElementArea(e){let t=Math.min(e.width,(window.innerWidth||document.documentElement.clientWidth)-e.left),i=Math.min(e.height,(window.innerHeight||document.documentElement.clientHeight)-e.top);return t*i}_getElementInfo(e){let t=e.nodeName.toLowerCase(),i={type:"",src:"",srcset:"",sizes:"",sources:[],bg_set:[],current_src:""};if("img"===t&&e.srcset)i.type="img-srcset",i.src=e.src,i.srcset=e.srcset,i.sizes=e.sizes,i.current_src=e.currentSrc;else if("img"===t)i.type="img",i.src=e.src,i.current_src=e.currentSrc;else if("video"===t){i.type="img";let n=e.querySelector("source");i.src=e.poster||(n?n.src:""),i.current_src=i.src}else if("svg"===t){let s=e.querySelector("image");s&&(i.type="img",i.src=s.getAttribute("href")||"",i.current_src=i.src)}else if("picture"===t){i.type="picture";let r=e.querySelector("img");i.src=r?r.src:"",i.sources=Array.from(e.querySelectorAll("source")).map(e=>({srcset:e.srcset||"",media:e.media||"",type:e.type||"",sizes:e.sizes||""}))}else{let c=window.getComputedStyle(e,null),o=[c.getPropertyValue("background-image"),getComputedStyle(e,":after").getPropertyValue("background-image"),getComputedStyle(e,":before").getPropertyValue("background-image")].filter(e=>"none"!==e);if(0===o.length)return null;let a=o[0];if(i.type="bg-img",a.includes("image-set(")&&(i.type="bg-img-set"),!a||""===a||a.includes("data:image"))return null;let l=[...a.matchAll(/url\(\s*?['"]?\s*?(.+?)\s*?["']?\s*?\)/ig)];i.bg_set=l.map(e=>e[1]?{src:e[1].trim()+(e[2]?" "+e[2].trim():"")}:{}),i.bg_set.every(e=>""===e.src)&&(i.bg_set=l.map(e=>e[1]?{src:e[1].trim()}:{})),i.bg_set.length>0&&(i.src=i.bg_set[0].src,"bg-img-set"===i.type&&(i.src=i.bg_set))}return i}_initWithFirstElementWithInfo(e){let t=e.find(e=>null!==e.elementInfo);if(!t){this._logMessage("No LCP candidate found."),this.performanceImages=[];return}this.performanceImages=[{...t.elementInfo,label:"lcp"}]}_fillATFWithoutDuplications(e){e.forEach(({element:e,elementInfo:t})=>{!this._isDuplicateImage(e)&&t&&this.performanceImages.push({...t,label:"above-the-fold"})})}_isDuplicateImage(e){let t=this._getElementInfo(e);if(null===t)return!1;let i="img"===t.type||"img-srcset"===t.type||"video"===t.type,n="bg-img"===t.type||"bg-img-set"===t.type||"picture"===t.type;return(i||n)&&this.performanceImages.some(e=>e.src===t.src)}_logMessage(e){this.config.debug&&console.log(e)}getResults(){return this.performanceImages}}RocketBeacon.run(); \ No newline at end of file +(()=>{var l=class{constructor(e){this.config=e,this.performanceImages=[],this.errorCode=""}async run(){try{const e=this._generateLcpCandidates(1/0);e&&(this._initWithFirstElementWithInfo(e),this._fillATFWithoutDuplications(e))}catch(e){this.errorCode="script_error",this._logMessage("Script Error: "+e)}}_generateLcpCandidates(e){const i=document.querySelectorAll(this.config.elements);return i.length<=0?[]:Array.from(i).map(n=>{if(n.nodeName.toLowerCase()==="img"&&n.parentElement.nodeName.toLowerCase()==="picture")return null;let s;if(n.nodeName.toLowerCase()==="picture"){const o=n.querySelector("img");if(o)s=o.getBoundingClientRect();else return null}else s=n.getBoundingClientRect();return{element:n,rect:s}}).filter(n=>n!==null).filter(n=>n.rect.width>0&&n.rect.height>0&&RocketBeacon._isIntersecting(n.rect)).map(n=>({item:n,area:this._getElementArea(n.rect),elementInfo:this._getElementInfo(n.element)})).sort((n,s)=>s.area-n.area).slice(0,e).map(n=>({element:n.item.element,elementInfo:n.elementInfo}))}_getElementArea(e){const i=Math.min(e.width,(window.innerWidth||document.documentElement.clientWidth)-e.left),t=Math.min(e.height,(window.innerHeight||document.documentElement.clientHeight)-e.top);return i*t}_getElementInfo(e){const i=e.nodeName.toLowerCase(),t={type:"",src:"",srcset:"",sizes:"",sources:[],bg_set:[],current_src:""},c=/url\(\s*?['"]?\s*?(.+?)\s*?["']?\s*?\)/ig;if(i==="img"&&e.srcset)t.type="img-srcset",t.src=e.src,t.srcset=e.srcset,t.sizes=e.sizes,t.current_src=e.currentSrc;else if(i==="img")t.type="img",t.src=e.src,t.current_src=e.currentSrc;else if(i==="video"){t.type="img";const n=e.querySelector("source");t.src=e.poster||(n?n.src:""),t.current_src=t.src}else if(i==="svg"){const n=e.querySelector("image");n&&(t.type="img",t.src=n.getAttribute("href")||"",t.current_src=t.src)}else if(i==="picture"){t.type="picture";const n=e.querySelector("img");t.src=n?n.src:"",t.sources=Array.from(e.querySelectorAll("source")).map(s=>({srcset:s.srcset||"",media:s.media||"",type:s.type||"",sizes:s.sizes||""}))}else{const s=[window.getComputedStyle(e,null).getPropertyValue("background-image"),getComputedStyle(e,":after").getPropertyValue("background-image"),getComputedStyle(e,":before").getPropertyValue("background-image")].filter(r=>r!=="none");if(s.length===0)return null;const o=s[0];if(t.type="bg-img",o.includes("image-set(")&&(t.type="bg-img-set"),!o||o===""||o.includes("data:image"))return null;const a=[...o.matchAll(c)];t.bg_set=a.map(r=>r[1]?{src:r[1].trim()+(r[2]?" "+r[2].trim():"")}:{}),t.bg_set.every(r=>r.src==="")&&(t.bg_set=a.map(r=>r[1]?{src:r[1].trim()}:{})),t.bg_set.length>0&&(t.src=t.bg_set[0].src,t.type==="bg-img-set"&&(t.src=t.bg_set))}return t}_initWithFirstElementWithInfo(e){const i=e.find(t=>t.elementInfo!==null);if(!i){this._logMessage("No LCP candidate found."),this.performanceImages=[];return}this.performanceImages=[{...i.elementInfo,label:"lcp"}]}_fillATFWithoutDuplications(e){e.forEach(({element:i,elementInfo:t})=>{this._isDuplicateImage(i)||!t||this.performanceImages.push({...t,label:"above-the-fold"})})}_isDuplicateImage(e){const i=this._getElementInfo(e);if(i===null)return!1;const t=i.type==="img"||i.type==="img-srcset"||i.type==="video",c=i.type==="bg-img"||i.type==="bg-img-set"||i.type==="picture";return(t||c)&&this.performanceImages.some(n=>n.src===i.src)}_logMessage(e){this.config.debug&&console.log(e)}getResults(){return this.performanceImages}},g=l,u=class{constructor(e){this.config=e,this.lcpBeacon=null,this.infiniteLoopId=null,this.scriptTimer=new Date,this.errorCode=""}async init(){if(!await this._isValidPreconditions()){this._finalize();return}this.infiniteLoopId=setTimeout(()=>{this._handleInfiniteLoop()},1e4),(await this._isGeneratedBefore()).lcp||(this.lcpBeacon=new g(this.config),await this.lcpBeacon.run()),this._saveFinalResultIntoDB()}async _isValidPreconditions(){return this._isNotValidScreensize()?(this._logMessage("Bailing out because screen size is not acceptable"),!1):this._isPageCached()&&await this._isGeneratedBefore()?(this._logMessage("Bailing out because data is already available"),!1):!0}_isPageCached(){const e=document.documentElement.nextSibling&&document.documentElement.nextSibling.data?document.documentElement.nextSibling.data:"";return e&&e.includes("Debug: cached")}async _isGeneratedBefore(){let e=new FormData;return e.append("action","rocket_check_beacon"),e.append("rocket_beacon_nonce",this.config.nonce),e.append("url",this.config.url),e.append("is_mobile",this.config.is_mobile),(await fetch(this.config.ajax_url,{method:"POST",credentials:"same-origin",body:e}).then(t=>t.json())).data}_isNotValidScreensize(){const e=window.innerWidth||document.documentElement.clientWidth,i=window.innerHeight||document.documentElement.clientHeight,t=this.config.is_mobile&&(e>this.config.width_threshold||i>this.config.height_threshold),c=!this.config.is_mobile&&(e=0&&e.right>=0&&e.top<=(window.innerHeight||document.documentElement.clientHeight)&&e.left<=(window.innerWidth||document.documentElement.clientWidth)}_saveFinalResultIntoDB(){const e=this.lcpBeacon?this.lcpBeacon.getResults():null,i=new FormData;i.append("action","rocket_beacon"),i.append("rocket_beacon_nonce",this.config.nonce),i.append("url",this.config.url),i.append("is_mobile",this.config.is_mobile),i.append("status",this._getFinalStatus()),i.append("lcp_images",JSON.stringify(e)),fetch(this.config.ajax_url,{method:"POST",credentials:"same-origin",body:i,headers:{"wpr-saas-no-intercept":!0}}).then(t=>t.json()).then(t=>{this._logMessage(t)}).catch(t=>{this._logMessage(t)}).finally(()=>{this._finalize()})}_getFinalStatus(){return this.errorCode!==""?this.errorCode:10<=(new Date-this.scriptTimer)/1e3?"timeout":"success"}_handleInfiniteLoop(){this._saveFinalResultIntoDB()}_finalize(){document.querySelector('[data-name="wpr-wpr-beacon"]').setAttribute("beacon-completed","true"),clearTimeout(this.infiniteLoopId)}_logMessage(e){this.config.debug&&console.log(e)}},d=u;(e=>{if(!e)return;const i=new d(e);if(document.readyState!=="loading"){setTimeout(()=>{i.init()},e.delay);return}document.addEventListener("DOMContentLoaded",()=>{setTimeout(()=>{i.init()},e.delay)})})(window.rocket_beacon_data)})(); +//# sourceMappingURL=wpr-beacon.min.js.map diff --git a/assets/js/wpr-beacon.min.js.map b/assets/js/wpr-beacon.min.js.map index c2ff8508a4..919e8ba0da 100644 --- a/assets/js/wpr-beacon.min.js.map +++ b/assets/js/wpr-beacon.min.js.map @@ -1 +1,7 @@ -{"version":3,"names":[],"mappings":"","sources":["wpr-beacon.min.js"],"sourcesContent":["!function n(r,s,o){function a(t,e){if(!s[t]){if(!r[t]){var i=\"function\"==typeof require&&require;if(!e&&i)return i(t,!0);if(c)return c(t,!0);throw(e=new Error(\"Cannot find module '\"+t+\"'\")).code=\"MODULE_NOT_FOUND\",e}i=s[t]={exports:{}},r[t][0].call(i.exports,function(e){return a(r[t][1][e]||e)},i,i.exports,n,r,s,o)}return s[t].exports}for(var c=\"function\"==typeof require&&require,e=0;e{this._handleInfiniteLoop()},1e4),(await this._isGeneratedBefore()).lcp||(this.lcpBeacon=new r(this.config),await this.lcpBeacon.run()),this._saveFinalResultIntoDB()):this._finalize()}async _isValidPreconditions(){return this._isNotValidScreensize()?(this._logMessage(\"Bailing out because screen size is not acceptable\"),!1):!this._isPageCached()||!await this._isGeneratedBefore()||(this._logMessage(\"Bailing out because data is already available\"),!1)}_isPageCached(){var e=document.documentElement.nextSibling&&document.documentElement.nextSibling.data?document.documentElement.nextSibling.data:\"\";return e&&e.includes(\"Debug: cached\")}async _isGeneratedBefore(){var e=new FormData,e=(e.append(\"action\",\"rocket_check_beacon\"),e.append(\"rocket_beacon_nonce\",this.config.nonce),e.append(\"url\",this.config.url),e.append(\"is_mobile\",this.config.is_mobile),await fetch(this.config.ajax_url,{method:\"POST\",credentials:\"same-origin\",body:e}).then(e=>e.json()));return e.data}_isNotValidScreensize(){var e=window.innerWidth||document.documentElement.clientWidth,t=window.innerHeight||document.documentElement.clientHeight,i=this.config.is_mobile&&(e>this.config.width_threshold||t>this.config.height_threshold),e=!this.config.is_mobile&&(ee.json()).then(e=>{this._logMessage(e)}).catch(e=>{this._logMessage(e)}).finally(()=>{this._finalize()})}_getFinalStatus(){return\"\"!==this.errorCode?this.errorCode:10<=(new Date-this.scriptTimer)/1e3?\"timeout\":\"success\"}_handleInfiniteLoop(){this._saveFinalResultIntoDB()}_finalize(){document.querySelector('[data-name=\"wpr-wpr-beacon\"]').setAttribute(\"beacon-completed\",\"true\"),clearTimeout(this.infiniteLoopId)}_logMessage(e){this.config.debug&&console.log(e)}static run(){if(window.rocket_beacon_data){let e=new n(window.rocket_beacon_data);\"loading\"!==document.readyState?setTimeout(()=>{e.init()},window.rocket_beacon_data.delay):document.addEventListener(\"DOMContentLoaded\",()=>{setTimeout(()=>{e.init()},window.rocket_beacon_data.delay)})}}}class r{constructor(e){this.config=e,this.performanceImages=[],this.errorCode=\"\"}async run(){try{var e=this._generateLcpCandidates(1/0);e&&(this._initWithFirstElementWithInfo(e),this._fillATFWithoutDuplications(e))}catch(e){this.errorCode=\"script_error\",this._logMessage(\"Script Error: \"+e)}}_generateLcpCandidates(e){var t=document.querySelectorAll(this.config.elements);return t.length<=0?[]:Array.from(t).map(e=>{if(\"img\"===e.nodeName.toLowerCase()&&\"picture\"===e.parentElement.nodeName.toLowerCase())return null;let t;if(\"picture\"===e.nodeName.toLowerCase()){var i=e.querySelector(\"img\");if(!i)return null;t=i.getBoundingClientRect()}else t=e.getBoundingClientRect();return{element:e,rect:t}}).filter(e=>null!==e).filter(e=>0({item:e,area:this._getElementArea(e.rect),elementInfo:this._getElementInfo(e.element)})).sort((e,t)=>t.area-e.area).slice(0,e).map(e=>({element:e.item.element,elementInfo:e.elementInfo}))}_getElementArea(e){return Math.min(e.width,(window.innerWidth||document.documentElement.clientWidth)-e.left)*Math.min(e.height,(window.innerHeight||document.documentElement.clientHeight)-e.top)}_getElementInfo(e){var t=e.nodeName.toLowerCase(),i={type:\"\",src:\"\",srcset:\"\",sizes:\"\",sources:[],bg_set:[],current_src:\"\"};if(\"img\"===t&&e.srcset)i.type=\"img-srcset\",i.src=e.src,i.srcset=e.srcset,i.sizes=e.sizes,i.current_src=e.currentSrc;else if(\"img\"===t)i.type=\"img\",i.src=e.src,i.current_src=e.currentSrc;else if(\"video\"===t){i.type=\"img\";var n=e.querySelector(\"source\");i.src=e.poster||(n?n.src:\"\"),i.current_src=i.src}else if(\"svg\"===t){n=e.querySelector(\"image\");n&&(i.type=\"img\",i.src=n.getAttribute(\"href\")||\"\",i.current_src=i.src)}else if(\"picture\"===t){i.type=\"picture\";n=e.querySelector(\"img\");i.src=n?n.src:\"\",i.sources=Array.from(e.querySelectorAll(\"source\")).map(e=>({srcset:e.srcset||\"\",media:e.media||\"\",type:e.type||\"\",sizes:e.sizes||\"\"}))}else{t=[window.getComputedStyle(e,null).getPropertyValue(\"background-image\"),getComputedStyle(e,\":after\").getPropertyValue(\"background-image\"),getComputedStyle(e,\":before\").getPropertyValue(\"background-image\")].filter(e=>\"none\"!==e);if(0===t.length)return null;n=t[0];if(i.type=\"bg-img\",n.includes(\"image-set(\")&&(i.type=\"bg-img-set\"),!n||\"\"===n||n.includes(\"data:image\"))return null;e=[...n.matchAll(/url\\(\\s*?['\"]?\\s*?(.+?)\\s*?[\"']?\\s*?\\)/gi)];i.bg_set=e.map(e=>e[1]?{src:e[1].trim()+(e[2]?\" \"+e[2].trim():\"\")}:{}),i.bg_set.every(e=>\"\"===e.src)&&(i.bg_set=e.map(e=>e[1]?{src:e[1].trim()}:{})),0null!==e.elementInfo);e?this.performanceImages=[{...e.elementInfo,label:\"lcp\"}]:(this._logMessage(\"No LCP candidate found.\"),this.performanceImages=[])}_fillATFWithoutDuplications(e){e.forEach(e=>{var{element:e,elementInfo:t}=e;!this._isDuplicateImage(e)&&t&&this.performanceImages.push({...t,label:\"above-the-fold\"})})}_isDuplicateImage(e){let t=this._getElementInfo(e);var i;return null!==t&&(e=\"img\"===t.type||\"img-srcset\"===t.type||\"video\"===t.type,i=\"bg-img\"===t.type||\"bg-img-set\"===t.type||\"picture\"===t.type,e||i)&&this.performanceImages.some(e=>e.src===t.src)}_logMessage(e){this.config.debug&&console.log(e)}getResults(){return this.performanceImages}}n.run()},{}]},{},[1]);"],"file":"wpr-beacon.min.js"} \ No newline at end of file +{ + "version": 3, + "sources": ["wpr-beacon.js"], + "sourcesContent": ["(() => {\n // src/RocketLcpBeacon.js\n var RocketLcpBeacon = class {\n constructor(config) {\n this.config = config;\n this.performanceImages = [];\n this.errorCode = \"\";\n }\n async run() {\n try {\n const above_the_fold_images = this._generateLcpCandidates(Infinity);\n if (above_the_fold_images) {\n this._initWithFirstElementWithInfo(above_the_fold_images);\n this._fillATFWithoutDuplications(above_the_fold_images);\n }\n } catch (err) {\n this.errorCode = \"script_error\";\n this._logMessage(\"Script Error: \" + err);\n }\n }\n _generateLcpCandidates(count) {\n const lcpElements = document.querySelectorAll(this.config.elements);\n if (lcpElements.length <= 0) {\n return [];\n }\n const potentialCandidates = Array.from(lcpElements);\n const topCandidates = potentialCandidates.map((element) => {\n if (\"img\" === element.nodeName.toLowerCase() && \"picture\" === element.parentElement.nodeName.toLowerCase()) {\n return null;\n }\n let rect;\n if (\"picture\" === element.nodeName.toLowerCase()) {\n const imgElement = element.querySelector(\"img\");\n if (imgElement) {\n rect = imgElement.getBoundingClientRect();\n } else {\n return null;\n }\n } else {\n rect = element.getBoundingClientRect();\n }\n return {\n element,\n rect\n };\n }).filter((item) => item !== null).filter((item) => {\n return item.rect.width > 0 && item.rect.height > 0 && RocketBeacon._isIntersecting(item.rect);\n }).map((item) => ({\n item,\n area: this._getElementArea(item.rect),\n elementInfo: this._getElementInfo(item.element)\n })).sort((a, b) => b.area - a.area).slice(0, count);\n return topCandidates.map((candidate) => ({\n element: candidate.item.element,\n elementInfo: candidate.elementInfo\n }));\n }\n _getElementArea(rect) {\n const visibleWidth = Math.min(rect.width, (window.innerWidth || document.documentElement.clientWidth) - rect.left);\n const visibleHeight = Math.min(rect.height, (window.innerHeight || document.documentElement.clientHeight) - rect.top);\n return visibleWidth * visibleHeight;\n }\n _getElementInfo(element) {\n const nodeName = element.nodeName.toLowerCase();\n const element_info = {\n type: \"\",\n src: \"\",\n srcset: \"\",\n sizes: \"\",\n sources: [],\n bg_set: [],\n current_src: \"\"\n };\n const css_bg_url_rgx = /url\\(\\s*?['\"]?\\s*?(.+?)\\s*?[\"']?\\s*?\\)/ig;\n if (nodeName === \"img\" && element.srcset) {\n element_info.type = \"img-srcset\";\n element_info.src = element.src;\n element_info.srcset = element.srcset;\n element_info.sizes = element.sizes;\n element_info.current_src = element.currentSrc;\n } else if (nodeName === \"img\") {\n element_info.type = \"img\";\n element_info.src = element.src;\n element_info.current_src = element.currentSrc;\n } else if (nodeName === \"video\") {\n element_info.type = \"img\";\n const source = element.querySelector(\"source\");\n element_info.src = element.poster || (source ? source.src : \"\");\n element_info.current_src = element_info.src;\n } else if (nodeName === \"svg\") {\n const imageElement = element.querySelector(\"image\");\n if (imageElement) {\n element_info.type = \"img\";\n element_info.src = imageElement.getAttribute(\"href\") || \"\";\n element_info.current_src = element_info.src;\n }\n } else if (nodeName === \"picture\") {\n element_info.type = \"picture\";\n const img = element.querySelector(\"img\");\n element_info.src = img ? img.src : \"\";\n element_info.sources = Array.from(element.querySelectorAll(\"source\")).map((source) => ({\n srcset: source.srcset || \"\",\n media: source.media || \"\",\n type: source.type || \"\",\n sizes: source.sizes || \"\"\n }));\n } else {\n const computed_style = window.getComputedStyle(element, null);\n const bg_props = [\n computed_style.getPropertyValue(\"background-image\"),\n getComputedStyle(element, \":after\").getPropertyValue(\"background-image\"),\n getComputedStyle(element, \":before\").getPropertyValue(\"background-image\")\n ].filter((prop) => prop !== \"none\");\n if (bg_props.length === 0) {\n return null;\n }\n const full_bg_prop = bg_props[0];\n element_info.type = \"bg-img\";\n if (full_bg_prop.includes(\"image-set(\")) {\n element_info.type = \"bg-img-set\";\n }\n if (!full_bg_prop || full_bg_prop === \"\" || full_bg_prop.includes(\"data:image\")) {\n return null;\n }\n const matches = [...full_bg_prop.matchAll(css_bg_url_rgx)];\n element_info.bg_set = matches.map((m) => m[1] ? { src: m[1].trim() + (m[2] ? \" \" + m[2].trim() : \"\") } : {});\n if (element_info.bg_set.every((item) => item.src === \"\")) {\n element_info.bg_set = matches.map((m) => m[1] ? { src: m[1].trim() } : {});\n }\n if (element_info.bg_set.length > 0) {\n element_info.src = element_info.bg_set[0].src;\n if (element_info.type === \"bg-img-set\") {\n element_info.src = element_info.bg_set;\n }\n }\n }\n return element_info;\n }\n _initWithFirstElementWithInfo(elements) {\n const firstElementWithInfo = elements.find((item) => item.elementInfo !== null);\n if (!firstElementWithInfo) {\n this._logMessage(\"No LCP candidate found.\");\n this.performanceImages = [];\n return;\n }\n this.performanceImages = [{\n ...firstElementWithInfo.elementInfo,\n label: \"lcp\"\n }];\n }\n _fillATFWithoutDuplications(elements) {\n elements.forEach(({ element, elementInfo }) => {\n if (this._isDuplicateImage(element) || !elementInfo) {\n return;\n }\n this.performanceImages.push({ ...elementInfo, label: \"above-the-fold\" });\n });\n }\n _isDuplicateImage(image) {\n const elementInfo = this._getElementInfo(image);\n if (elementInfo === null) {\n return false;\n }\n const isImageOrVideo = elementInfo.type === \"img\" || elementInfo.type === \"img-srcset\" || elementInfo.type === \"video\";\n const isBgImageOrPicture = elementInfo.type === \"bg-img\" || elementInfo.type === \"bg-img-set\" || elementInfo.type === \"picture\";\n return (isImageOrVideo || isBgImageOrPicture) && this.performanceImages.some((item) => item.src === elementInfo.src);\n }\n _logMessage(msg) {\n if (!this.config.debug) {\n return;\n }\n console.log(msg);\n }\n getResults() {\n return this.performanceImages;\n }\n };\n var RocketLcpBeacon_default = RocketLcpBeacon;\n\n // src/RocketBeacon.js\n var RocketBeacon2 = class {\n constructor(config) {\n this.config = config;\n this.lcpBeacon = null;\n this.infiniteLoopId = null;\n this.scriptTimer = /* @__PURE__ */ new Date();\n this.errorCode = \"\";\n }\n async init() {\n if (!await this._isValidPreconditions()) {\n this._finalize();\n return;\n }\n this.infiniteLoopId = setTimeout(() => {\n this._handleInfiniteLoop();\n }, 1e4);\n const isGeneratedBefore = await this._isGeneratedBefore();\n if (!isGeneratedBefore.lcp) {\n this.lcpBeacon = new RocketLcpBeacon_default(this.config);\n await this.lcpBeacon.run();\n }\n this._saveFinalResultIntoDB();\n }\n async _isValidPreconditions() {\n if (this._isNotValidScreensize()) {\n this._logMessage(\"Bailing out because screen size is not acceptable\");\n return false;\n }\n if (this._isPageCached() && await this._isGeneratedBefore()) {\n this._logMessage(\"Bailing out because data is already available\");\n return false;\n }\n return true;\n }\n _isPageCached() {\n const signature = document.documentElement.nextSibling && document.documentElement.nextSibling.data ? document.documentElement.nextSibling.data : \"\";\n return signature && signature.includes(\"Debug: cached\");\n }\n async _isGeneratedBefore() {\n let data_check = new FormData();\n data_check.append(\"action\", \"rocket_check_beacon\");\n data_check.append(\"rocket_beacon_nonce\", this.config.nonce);\n data_check.append(\"url\", this.config.url);\n data_check.append(\"is_mobile\", this.config.is_mobile);\n const beacon_data_response = await fetch(this.config.ajax_url, {\n method: \"POST\",\n credentials: \"same-origin\",\n body: data_check\n }).then((data) => data.json());\n return beacon_data_response.data;\n }\n _isNotValidScreensize() {\n const screenWidth = window.innerWidth || document.documentElement.clientWidth;\n const screenHeight = window.innerHeight || document.documentElement.clientHeight;\n const isNotValidForMobile = this.config.is_mobile && (screenWidth > this.config.width_threshold || screenHeight > this.config.height_threshold);\n const isNotValidForDesktop = !this.config.is_mobile && (screenWidth < this.config.width_threshold || screenHeight < this.config.height_threshold);\n return isNotValidForMobile || isNotValidForDesktop;\n }\n static _isIntersecting(rect) {\n return rect.bottom >= 0 && rect.right >= 0 && rect.top <= (window.innerHeight || document.documentElement.clientHeight) && rect.left <= (window.innerWidth || document.documentElement.clientWidth);\n }\n _saveFinalResultIntoDB() {\n const lcpResults = this.lcpBeacon ? this.lcpBeacon.getResults() : null;\n const data = new FormData();\n data.append(\"action\", \"rocket_beacon\");\n data.append(\"rocket_beacon_nonce\", this.config.nonce);\n data.append(\"url\", this.config.url);\n data.append(\"is_mobile\", this.config.is_mobile);\n data.append(\"status\", this._getFinalStatus());\n data.append(\"lcp_images\", JSON.stringify(lcpResults));\n fetch(this.config.ajax_url, {\n method: \"POST\",\n credentials: \"same-origin\",\n body: data,\n headers: {\n \"wpr-saas-no-intercept\": true\n }\n }).then((response) => response.json()).then((data2) => {\n this._logMessage(data2);\n }).catch((error) => {\n this._logMessage(error);\n }).finally(() => {\n this._finalize();\n });\n }\n _getFinalStatus() {\n if (\"\" !== this.errorCode) {\n return this.errorCode;\n }\n const scriptTime = (/* @__PURE__ */ new Date() - this.scriptTimer) / 1e3;\n if (10 <= scriptTime) {\n return \"timeout\";\n }\n return \"success\";\n }\n _handleInfiniteLoop() {\n this._saveFinalResultIntoDB();\n }\n _finalize() {\n const beaconscript = document.querySelector('[data-name=\"wpr-wpr-beacon\"]');\n beaconscript.setAttribute(\"beacon-completed\", \"true\");\n clearTimeout(this.infiniteLoopId);\n }\n _logMessage(msg) {\n if (!this.config.debug) {\n return;\n }\n console.log(msg);\n }\n };\n var RocketBeacon_default = RocketBeacon2;\n\n // src/RocketFinalBeacon.js\n ((rocket_beacon_data) => {\n if (!rocket_beacon_data) {\n return;\n }\n const instance = new RocketBeacon_default(rocket_beacon_data);\n if (document.readyState !== \"loading\") {\n setTimeout(() => {\n instance.init();\n }, rocket_beacon_data.delay);\n return;\n }\n document.addEventListener(\"DOMContentLoaded\", () => {\n setTimeout(() => {\n instance.init();\n }, rocket_beacon_data.delay);\n });\n })(window.rocket_beacon_data);\n})();\n"], + "mappings": "CAAC,IAAM,CAEL,IAAIA,EAAkB,KAAM,CAC1B,YAAYC,EAAQ,CAClB,KAAK,OAASA,EACd,KAAK,kBAAoB,CAAC,EAC1B,KAAK,UAAY,EACnB,CACA,MAAM,KAAM,CACV,GAAI,CACF,MAAMC,EAAwB,KAAK,uBAAuB,GAAQ,EAC9DA,IACF,KAAK,8BAA8BA,CAAqB,EACxD,KAAK,4BAA4BA,CAAqB,EAE1D,OAASC,EAAK,CACZ,KAAK,UAAY,eACjB,KAAK,YAAY,iBAAmBA,CAAG,CACzC,CACF,CACA,uBAAuBC,EAAO,CAC5B,MAAMC,EAAc,SAAS,iBAAiB,KAAK,OAAO,QAAQ,EAClE,OAAIA,EAAY,QAAU,EACjB,CAAC,EAEkB,MAAM,KAAKA,CAAW,EACR,IAAKC,GAAY,CACzD,GAAcA,EAAQ,SAAS,YAAY,IAAvC,OAA0DA,EAAQ,cAAc,SAAS,YAAY,IAAzD,UAC9C,OAAO,KAET,IAAIC,EACJ,GAAkBD,EAAQ,SAAS,YAAY,IAA3C,UAA8C,CAChD,MAAME,EAAaF,EAAQ,cAAc,KAAK,EAC9C,GAAIE,EACFD,EAAOC,EAAW,sBAAsB,MAExC,QAAO,IAEX,MACED,EAAOD,EAAQ,sBAAsB,EAEvC,MAAO,CACL,QAAAA,EACA,KAAAC,CACF,CACF,CAAC,EAAE,OAAQE,GAASA,IAAS,IAAI,EAAE,OAAQA,GAClCA,EAAK,KAAK,MAAQ,GAAKA,EAAK,KAAK,OAAS,GAAK,aAAa,gBAAgBA,EAAK,IAAI,CAC7F,EAAE,IAAKA,IAAU,CAChB,KAAAA,EACA,KAAM,KAAK,gBAAgBA,EAAK,IAAI,EACpC,YAAa,KAAK,gBAAgBA,EAAK,OAAO,CAChD,EAAE,EAAE,KAAK,CAACC,EAAGC,IAAMA,EAAE,KAAOD,EAAE,IAAI,EAAE,MAAM,EAAGN,CAAK,EAC7B,IAAKQ,IAAe,CACvC,QAASA,EAAU,KAAK,QACxB,YAAaA,EAAU,WACzB,EAAE,CACJ,CACA,gBAAgBL,EAAM,CACpB,MAAMM,EAAe,KAAK,IAAIN,EAAK,OAAQ,OAAO,YAAc,SAAS,gBAAgB,aAAeA,EAAK,IAAI,EAC3GO,EAAgB,KAAK,IAAIP,EAAK,QAAS,OAAO,aAAe,SAAS,gBAAgB,cAAgBA,EAAK,GAAG,EACpH,OAAOM,EAAeC,CACxB,CACA,gBAAgBR,EAAS,CACvB,MAAMS,EAAWT,EAAQ,SAAS,YAAY,EACxCU,EAAe,CACnB,KAAM,GACN,IAAK,GACL,OAAQ,GACR,MAAO,GACP,QAAS,CAAC,EACV,OAAQ,CAAC,EACT,YAAa,EACf,EACMC,EAAiB,2CACvB,GAAIF,IAAa,OAAST,EAAQ,OAChCU,EAAa,KAAO,aACpBA,EAAa,IAAMV,EAAQ,IAC3BU,EAAa,OAASV,EAAQ,OAC9BU,EAAa,MAAQV,EAAQ,MAC7BU,EAAa,YAAcV,EAAQ,mBAC1BS,IAAa,MACtBC,EAAa,KAAO,MACpBA,EAAa,IAAMV,EAAQ,IAC3BU,EAAa,YAAcV,EAAQ,mBAC1BS,IAAa,QAAS,CAC/BC,EAAa,KAAO,MACpB,MAAME,EAASZ,EAAQ,cAAc,QAAQ,EAC7CU,EAAa,IAAMV,EAAQ,SAAWY,EAASA,EAAO,IAAM,IAC5DF,EAAa,YAAcA,EAAa,GAC1C,SAAWD,IAAa,MAAO,CAC7B,MAAMI,EAAeb,EAAQ,cAAc,OAAO,EAC9Ca,IACFH,EAAa,KAAO,MACpBA,EAAa,IAAMG,EAAa,aAAa,MAAM,GAAK,GACxDH,EAAa,YAAcA,EAAa,IAE5C,SAAWD,IAAa,UAAW,CACjCC,EAAa,KAAO,UACpB,MAAMI,EAAMd,EAAQ,cAAc,KAAK,EACvCU,EAAa,IAAMI,EAAMA,EAAI,IAAM,GACnCJ,EAAa,QAAU,MAAM,KAAKV,EAAQ,iBAAiB,QAAQ,CAAC,EAAE,IAAKY,IAAY,CACrF,OAAQA,EAAO,QAAU,GACzB,MAAOA,EAAO,OAAS,GACvB,KAAMA,EAAO,MAAQ,GACrB,MAAOA,EAAO,OAAS,EACzB,EAAE,CACJ,KAAO,CAEL,MAAMG,EAAW,CADM,OAAO,iBAAiBf,EAAS,IAAI,EAE3C,iBAAiB,kBAAkB,EAClD,iBAAiBA,EAAS,QAAQ,EAAE,iBAAiB,kBAAkB,EACvE,iBAAiBA,EAAS,SAAS,EAAE,iBAAiB,kBAAkB,CAC1E,EAAE,OAAQgB,GAASA,IAAS,MAAM,EAClC,GAAID,EAAS,SAAW,EACtB,OAAO,KAET,MAAME,EAAeF,EAAS,CAAC,EAK/B,GAJAL,EAAa,KAAO,SAChBO,EAAa,SAAS,YAAY,IACpCP,EAAa,KAAO,cAElB,CAACO,GAAgBA,IAAiB,IAAMA,EAAa,SAAS,YAAY,EAC5E,OAAO,KAET,MAAMC,EAAU,CAAC,GAAGD,EAAa,SAASN,CAAc,CAAC,EACzDD,EAAa,OAASQ,EAAQ,IAAKC,GAAMA,EAAE,CAAC,EAAI,CAAE,IAAKA,EAAE,CAAC,EAAE,KAAK,GAAKA,EAAE,CAAC,EAAI,IAAMA,EAAE,CAAC,EAAE,KAAK,EAAI,GAAI,EAAI,CAAC,CAAC,EACvGT,EAAa,OAAO,MAAOP,GAASA,EAAK,MAAQ,EAAE,IACrDO,EAAa,OAASQ,EAAQ,IAAKC,GAAMA,EAAE,CAAC,EAAI,CAAE,IAAKA,EAAE,CAAC,EAAE,KAAK,CAAE,EAAI,CAAC,CAAC,GAEvET,EAAa,OAAO,OAAS,IAC/BA,EAAa,IAAMA,EAAa,OAAO,CAAC,EAAE,IACtCA,EAAa,OAAS,eACxBA,EAAa,IAAMA,EAAa,QAGtC,CACA,OAAOA,CACT,CACA,8BAA8BU,EAAU,CACtC,MAAMC,EAAuBD,EAAS,KAAMjB,GAASA,EAAK,cAAgB,IAAI,EAC9E,GAAI,CAACkB,EAAsB,CACzB,KAAK,YAAY,yBAAyB,EAC1C,KAAK,kBAAoB,CAAC,EAC1B,MACF,CACA,KAAK,kBAAoB,CAAC,CACxB,GAAGA,EAAqB,YACxB,MAAO,KACT,CAAC,CACH,CACA,4BAA4BD,EAAU,CACpCA,EAAS,QAAQ,CAAC,CAAE,QAAApB,EAAS,YAAAsB,CAAY,IAAM,CACzC,KAAK,kBAAkBtB,CAAO,GAAK,CAACsB,GAGxC,KAAK,kBAAkB,KAAK,CAAE,GAAGA,EAAa,MAAO,gBAAiB,CAAC,CACzE,CAAC,CACH,CACA,kBAAkBC,EAAO,CACvB,MAAMD,EAAc,KAAK,gBAAgBC,CAAK,EAC9C,GAAID,IAAgB,KAClB,MAAO,GAET,MAAME,EAAiBF,EAAY,OAAS,OAASA,EAAY,OAAS,cAAgBA,EAAY,OAAS,QACzGG,EAAqBH,EAAY,OAAS,UAAYA,EAAY,OAAS,cAAgBA,EAAY,OAAS,UACtH,OAAQE,GAAkBC,IAAuB,KAAK,kBAAkB,KAAMtB,GAASA,EAAK,MAAQmB,EAAY,GAAG,CACrH,CACA,YAAYI,EAAK,CACV,KAAK,OAAO,OAGjB,QAAQ,IAAIA,CAAG,CACjB,CACA,YAAa,CACX,OAAO,KAAK,iBACd,CACF,EACIC,EAA0BjC,EAG1BkC,EAAgB,KAAM,CACxB,YAAYjC,EAAQ,CAClB,KAAK,OAASA,EACd,KAAK,UAAY,KACjB,KAAK,eAAiB,KACtB,KAAK,YAA8B,IAAI,KACvC,KAAK,UAAY,EACnB,CACA,MAAM,MAAO,CACX,GAAI,CAAC,MAAM,KAAK,sBAAsB,EAAG,CACvC,KAAK,UAAU,EACf,MACF,CACA,KAAK,eAAiB,WAAW,IAAM,CACrC,KAAK,oBAAoB,CAC3B,EAAG,GAAG,GACoB,MAAM,KAAK,mBAAmB,GACjC,MACrB,KAAK,UAAY,IAAIgC,EAAwB,KAAK,MAAM,EACxD,MAAM,KAAK,UAAU,IAAI,GAE3B,KAAK,uBAAuB,CAC9B,CACA,MAAM,uBAAwB,CAC5B,OAAI,KAAK,sBAAsB,GAC7B,KAAK,YAAY,mDAAmD,EAC7D,IAEL,KAAK,cAAc,GAAK,MAAM,KAAK,mBAAmB,GACxD,KAAK,YAAY,+CAA+C,EACzD,IAEF,EACT,CACA,eAAgB,CACd,MAAME,EAAY,SAAS,gBAAgB,aAAe,SAAS,gBAAgB,YAAY,KAAO,SAAS,gBAAgB,YAAY,KAAO,GAClJ,OAAOA,GAAaA,EAAU,SAAS,eAAe,CACxD,CACA,MAAM,oBAAqB,CACzB,IAAIC,EAAa,IAAI,SACrB,OAAAA,EAAW,OAAO,SAAU,qBAAqB,EACjDA,EAAW,OAAO,sBAAuB,KAAK,OAAO,KAAK,EAC1DA,EAAW,OAAO,MAAO,KAAK,OAAO,GAAG,EACxCA,EAAW,OAAO,YAAa,KAAK,OAAO,SAAS,GACvB,MAAM,MAAM,KAAK,OAAO,SAAU,CAC7D,OAAQ,OACR,YAAa,cACb,KAAMA,CACR,CAAC,EAAE,KAAMC,GAASA,EAAK,KAAK,CAAC,GACD,IAC9B,CACA,uBAAwB,CACtB,MAAMC,EAAc,OAAO,YAAc,SAAS,gBAAgB,YAC5DC,EAAe,OAAO,aAAe,SAAS,gBAAgB,aAC9DC,EAAsB,KAAK,OAAO,YAAcF,EAAc,KAAK,OAAO,iBAAmBC,EAAe,KAAK,OAAO,kBACxHE,EAAuB,CAAC,KAAK,OAAO,YAAcH,EAAc,KAAK,OAAO,iBAAmBC,EAAe,KAAK,OAAO,kBAChI,OAAOC,GAAuBC,CAChC,CACA,OAAO,gBAAgBlC,EAAM,CAC3B,OAAOA,EAAK,QAAU,GAAKA,EAAK,OAAS,GAAKA,EAAK,MAAQ,OAAO,aAAe,SAAS,gBAAgB,eAAiBA,EAAK,OAAS,OAAO,YAAc,SAAS,gBAAgB,YACzL,CACA,wBAAyB,CACvB,MAAMmC,EAAa,KAAK,UAAY,KAAK,UAAU,WAAW,EAAI,KAC5DL,EAAO,IAAI,SACjBA,EAAK,OAAO,SAAU,eAAe,EACrCA,EAAK,OAAO,sBAAuB,KAAK,OAAO,KAAK,EACpDA,EAAK,OAAO,MAAO,KAAK,OAAO,GAAG,EAClCA,EAAK,OAAO,YAAa,KAAK,OAAO,SAAS,EAC9CA,EAAK,OAAO,SAAU,KAAK,gBAAgB,CAAC,EAC5CA,EAAK,OAAO,aAAc,KAAK,UAAUK,CAAU,CAAC,EACpD,MAAM,KAAK,OAAO,SAAU,CAC1B,OAAQ,OACR,YAAa,cACb,KAAML,EACN,QAAS,CACP,wBAAyB,EAC3B,CACF,CAAC,EAAE,KAAMM,GAAaA,EAAS,KAAK,CAAC,EAAE,KAAMC,GAAU,CACrD,KAAK,YAAYA,CAAK,CACxB,CAAC,EAAE,MAAOC,GAAU,CAClB,KAAK,YAAYA,CAAK,CACxB,CAAC,EAAE,QAAQ,IAAM,CACf,KAAK,UAAU,CACjB,CAAC,CACH,CACA,iBAAkB,CAChB,OAAW,KAAK,YAAZ,GACK,KAAK,UAGV,KADgC,IAAI,KAAS,KAAK,aAAe,IAE5D,UAEF,SACT,CACA,qBAAsB,CACpB,KAAK,uBAAuB,CAC9B,CACA,WAAY,CACW,SAAS,cAAc,8BAA8B,EAC7D,aAAa,mBAAoB,MAAM,EACpD,aAAa,KAAK,cAAc,CAClC,CACA,YAAYb,EAAK,CACV,KAAK,OAAO,OAGjB,QAAQ,IAAIA,CAAG,CACjB,CACF,EACIc,EAAuBZ,GAGzBa,GAAuB,CACvB,GAAI,CAACA,EACH,OAEF,MAAMC,EAAW,IAAIF,EAAqBC,CAAkB,EAC5D,GAAI,SAAS,aAAe,UAAW,CACrC,WAAW,IAAM,CACfC,EAAS,KAAK,CAChB,EAAGD,EAAmB,KAAK,EAC3B,MACF,CACA,SAAS,iBAAiB,mBAAoB,IAAM,CAClD,WAAW,IAAM,CACfC,EAAS,KAAK,CAChB,EAAGD,EAAmB,KAAK,CAC7B,CAAC,CACH,GAAG,OAAO,kBAAkB,CAC9B,GAAG", + "names": ["RocketLcpBeacon", "config", "above_the_fold_images", "err", "count", "lcpElements", "element", "rect", "imgElement", "item", "a", "b", "candidate", "visibleWidth", "visibleHeight", "nodeName", "element_info", "css_bg_url_rgx", "source", "imageElement", "img", "bg_props", "prop", "full_bg_prop", "matches", "m", "elements", "firstElementWithInfo", "elementInfo", "image", "isImageOrVideo", "isBgImageOrPicture", "msg", "RocketLcpBeacon_default", "RocketBeacon2", "signature", "data_check", "data", "screenWidth", "screenHeight", "isNotValidForMobile", "isNotValidForDesktop", "lcpResults", "response", "data2", "error", "RocketBeacon_default", "rocket_beacon_data", "instance"] +} diff --git a/gulpfile.js b/gulpfile.js index 91f26a379a..b721ded0bb 100755 --- a/gulpfile.js +++ b/gulpfile.js @@ -18,7 +18,7 @@ requireDir('./src/js/gulp/tasks', { recurse: true }); * gulp build:js:app:min => Builds admin app js file, the minified version (wpr-admin.min.js) * gulp build:js:lazyloadcss:min => Builds lazyload CSS js file, the minified version (lazyload-css.min.js) * gulp build:js:all => Builds all js files mentioned above (wpr-admin.js, wpr-admin.min.js, lazyload-css.min.js, wpr-beacon.min.js) -* gulp build:js:lcp => Builds lcp beacon script, the minified version (lcp-beacon.min.js, source file, and map file) +* gulp build:js:lcp => Builds lcp beacon script, the minified version (wpr-beacon.min.js, source file, and map file) * gulp js:watch => Watches all js files changes and build them again with any change. * */ diff --git a/package-lock.json b/package-lock.json index c1d49b6e54..49e41f066c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,8 +12,7 @@ "isomorphic-fetch": "^3.0", "prop-types": "^15.6.2", "react": "^16.5.2", - "react-dom": "^16.5.2", - "wp-rocket-scripts": "^1.0.1" + "react-dom": "^16.5.2" }, "devDependencies": { "@babel/core": "^7.16.0", @@ -44,6 +43,7 @@ "watchify": "^4.0.0", "webpack": "^5.76.0", "webpack-cli": "^4.9.1", + "wp-rocket-scripts": "github:wp-media/rocket-scripts#refactor-beacon-before-wpr-3.17", "yargs": "^17.3.0" } }, @@ -74,30 +74,30 @@ } }, "node_modules/@babel/compat-data": { - "version": "7.24.8", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.24.8.tgz", - "integrity": "sha512-c4IM7OTg6k1Q+AJ153e2mc2QVTezTwnb4VzquwcyiEzGnW0Kedv4do/TrkU98qPeC5LNiMt/QXwIjzYXLBpyZg==", + "version": "7.24.9", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.24.9.tgz", + "integrity": "sha512-e701mcfApCJqMMueQI0Fb68Amflj83+dvAvHawoBpAz+GDjCIyGHzNwnefjsWJ3xiYAqqiQFoWbspGYBdb2/ng==", "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/core": { - "version": "7.24.8", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.24.8.tgz", - "integrity": "sha512-6AWcmZC/MZCO0yKys4uhg5NlxL0ESF3K6IAaoQ+xSXvPyPyxNWRafP+GDbI88Oh68O7QkJgmEtedWPM9U0pZNg==", + "version": "7.24.9", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.24.9.tgz", + "integrity": "sha512-5e3FI4Q3M3Pbr21+5xJwCv6ZT6KmGkI0vw3Tozy5ODAQFTIWe37iT8Cr7Ice2Ntb+M3iSKCEWMB1MBgKrW3whg==", "dev": true, "dependencies": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.24.7", - "@babel/generator": "^7.24.8", + "@babel/generator": "^7.24.9", "@babel/helper-compilation-targets": "^7.24.8", - "@babel/helper-module-transforms": "^7.24.8", + "@babel/helper-module-transforms": "^7.24.9", "@babel/helpers": "^7.24.8", "@babel/parser": "^7.24.8", "@babel/template": "^7.24.7", "@babel/traverse": "^7.24.8", - "@babel/types": "^7.24.8", + "@babel/types": "^7.24.9", "convert-source-map": "^2.0.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", @@ -131,12 +131,12 @@ } }, "node_modules/@babel/generator": { - "version": "7.24.8", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.24.8.tgz", - "integrity": "sha512-47DG+6F5SzOi0uEvK4wMShmn5yY0mVjVJoWTphdY2B4Rx9wHgjK7Yhtr0ru6nE+sn0v38mzrWOlah0p/YlHHOQ==", + "version": "7.24.10", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.24.10.tgz", + "integrity": "sha512-o9HBZL1G2129luEUlG1hB4N/nlYNWHnpwlND9eOMclRqqu1YDy2sSYVCFUZwl8I1Gxh+QSRrP2vD7EpUmFVXxg==", "dev": true, "dependencies": { - "@babel/types": "^7.24.8", + "@babel/types": "^7.24.9", "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.25", "jsesc": "^2.5.1" @@ -306,9 +306,9 @@ } }, "node_modules/@babel/helper-module-transforms": { - "version": "7.24.8", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.24.8.tgz", - "integrity": "sha512-m4vWKVqvkVAWLXfHCCfff2luJj86U+J0/x+0N3ArG/tP0Fq7zky2dYwMbtPmkc/oulkkbjdL3uWzuoBwQ8R00Q==", + "version": "7.24.9", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.24.9.tgz", + "integrity": "sha512-oYbh+rtFKj/HwBQkFlUzvcybzklmVdVV3UU+mN7n2t/q3yGHbuVdNxyFvSBO1tfvjyArpHNcWMAzsSPdyI46hw==", "dev": true, "dependencies": { "@babel/helper-environment-visitor": "^7.24.7", @@ -1867,9 +1867,9 @@ } }, "node_modules/@babel/types": { - "version": "7.24.8", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.24.8.tgz", - "integrity": "sha512-SkSBEHwwJRU52QEVZBmMBnE5Ux2/6WU1grdYyOhpbCNxbmJrDuDCphBzKZSO3taf0zztp+qkWlymE5tVL5l0TA==", + "version": "7.24.9", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.24.9.tgz", + "integrity": "sha512-xm8XrMKz0IlUdocVbYJe0Z9xEgidU7msskG8BbhnTPK/HZ2z/7FP7ykqPgrUH+C+r414mNfNWam1f2vqOjqjYQ==", "dev": true, "dependencies": { "@babel/helper-string-parser": "^7.24.8", @@ -2203,9 +2203,9 @@ } }, "node_modules/@types/eslint": { - "version": "8.56.10", - "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.10.tgz", - "integrity": "sha512-Shavhk87gCtY2fhXDctcfS3e6FdxWkCx1iUZ9eEUbh7rTqlZT0/IzOkCOVt0fCjcFuZ9FPYfuezTBImfHCDBGQ==", + "version": "9.6.0", + "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-9.6.0.tgz", + "integrity": "sha512-gi6WQJ7cHRgZxtkQEoyHMppPjq9Kxo5Tjn2prSKDSmZrCz8TZ3jSRCeTJm+WoM+oB0WG37bRqLzaaU3q7JypGg==", "dev": true, "dependencies": { "@types/estree": "*", @@ -2241,9 +2241,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.14.10", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.10.tgz", - "integrity": "sha512-MdiXf+nDuMvY0gJKxyfZ7/6UFsETO7mGKF54MVD/ekJS6HdFtpZFBgrh6Pseu64XTb2MLyFPlbW6hj8HYRQNOQ==", + "version": "20.14.11", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.11.tgz", + "integrity": "sha512-kprQpL8MMeszbz6ojB5/tU8PLN4kesnN8Gjzw349rDlNgsSzg90lAVj3llK99Dh7JON+t9AuscPPFW6mPbTnSA==", "dev": true, "dependencies": { "undici-types": "~5.26.4" @@ -2745,18 +2745,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/array.prototype.toreversed": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/array.prototype.toreversed/-/array.prototype.toreversed-1.1.2.tgz", - "integrity": "sha512-wwDCoT4Ck4Cz7sLtgUmzR5UV3YF5mFHUlbChCzZBQZ+0m2cl/DH3tKgvphv1nKgFsJ48oCSg6p91q2Vm0I/ZMA==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.2.0", - "es-abstract": "^1.22.1", - "es-shim-unscopables": "^1.0.0" - } - }, "node_modules/array.prototype.tosorted": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/array.prototype.tosorted/-/array.prototype.tosorted-1.1.4.tgz", @@ -4054,9 +4042,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001641", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001641.tgz", - "integrity": "sha512-Phv5thgl67bHYo1TtMY/MurjkHhV4EDaCosezRXgZ8jzA/Ub+wjxAvbGvjoFENStinwi5kCyOYV3mi5tOGykwA==", + "version": "1.0.30001643", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001643.tgz", + "integrity": "sha512-ERgWGNleEilSrHM6iUz/zJNSQTP8Mr21wDWpdgvRwcTXGAq6jMtOUPP4dqFPTdKqZ2wKTdtB+uucZ3MRpAUSmg==", "dev": true, "funding": [ { @@ -4751,15 +4739,15 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.827", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.827.tgz", - "integrity": "sha512-VY+J0e4SFcNfQy19MEoMdaIcZLmDCprqvBtkii1WTCTQHpRvf5N8+3kTYCgL/PcntvwQvmMJWTuDPsq+IlhWKQ==", + "version": "1.4.833", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.833.tgz", + "integrity": "sha512-aVGP9xK70Ysrzip1m5LoJjCp1EDrYzZ7Pg/O3QR1h3PAhmc8SNfSXV3kmmtkg5rNO42EcTYmLX3eFMgqALlGIA==", "dev": true }, "node_modules/elliptic": { - "version": "6.5.5", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.5.tgz", - "integrity": "sha512-7EjbcmUm17NQFu4Pmgmq2olYMj8nwMnpcddByChSUjArp8F5DQWcIcpriwO4ZToLNAJig0yiyjswfyGNje/ixw==", + "version": "6.5.6", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.6.tgz", + "integrity": "sha512-mpzdtpeCLuS3BmE3pO3Cpp5bbjlOPY2Q0PgoF+Od1XZrHLYI28Xe3ossCmYCQt11FQKEYd9+PF8jymTvtWJSHQ==", "dev": true, "dependencies": { "bn.js": "^4.11.9", @@ -5214,35 +5202,35 @@ } }, "node_modules/eslint-plugin-react": { - "version": "7.34.3", - "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.34.3.tgz", - "integrity": "sha512-aoW4MV891jkUulwDApQbPYTVZmeuSyFrudpbTAQuj5Fv8VL+o6df2xIGpw8B0hPjAaih1/Fb0om9grCdyFYemA==", + "version": "7.35.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.35.0.tgz", + "integrity": "sha512-v501SSMOWv8gerHkk+IIQBkcGRGrO2nfybfj5pLxuJNFTPxxA3PSryhXTK+9pNbtkggheDdsC0E9Q8CuPk6JKA==", "dev": true, "dependencies": { "array-includes": "^3.1.8", "array.prototype.findlast": "^1.2.5", "array.prototype.flatmap": "^1.3.2", - "array.prototype.toreversed": "^1.1.2", "array.prototype.tosorted": "^1.1.4", "doctrine": "^2.1.0", "es-iterator-helpers": "^1.0.19", "estraverse": "^5.3.0", + "hasown": "^2.0.2", "jsx-ast-utils": "^2.4.1 || ^3.0.0", "minimatch": "^3.1.2", "object.entries": "^1.1.8", "object.fromentries": "^2.0.8", - "object.hasown": "^1.1.4", "object.values": "^1.2.0", "prop-types": "^15.8.1", "resolve": "^2.0.0-next.5", "semver": "^6.3.1", - "string.prototype.matchall": "^4.0.11" + "string.prototype.matchall": "^4.0.11", + "string.prototype.repeat": "^1.0.0" }, "engines": { "node": ">=4" }, "peerDependencies": { - "eslint": "^3 || ^4 || ^5 || ^6 || ^7 || ^8" + "eslint": "^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9.7" } }, "node_modules/eslint-plugin-react/node_modules/doctrine": { @@ -6670,9 +6658,9 @@ } }, "node_modules/immutable": { - "version": "4.3.6", - "resolved": "https://registry.npmjs.org/immutable/-/immutable-4.3.6.tgz", - "integrity": "sha512-Ju0+lEMyzMVZarkTn/gqRpdqd5dOPaz1mCZ0SH3JV6iFw81PldE/PEB1hWVEA288HPt4WXW8O7AWxB10M+03QQ==", + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/immutable/-/immutable-4.3.7.tgz", + "integrity": "sha512-1hqclzwYwjRDFLjcFxOM5AYkkG0rpFPpr1RLPMEuGczoS7YA8gLhy8SWXYRAA/XwfEHpfo3cw5JGioS32fnMRw==", "dev": true }, "node_modules/import-fresh": { @@ -6692,9 +6680,9 @@ } }, "node_modules/import-local": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.1.0.tgz", - "integrity": "sha512-ASB07uLtnDs1o6EHjKpX34BKYDSqnFerfTOJL2HvMqF70LnxpjkzDB8J44oT9pu4AMPkQwf8jl6szgvNd2tRIg==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.2.0.tgz", + "integrity": "sha512-2SPlun1JUPWoM6t3F0dw0FkCF/jWY8kttcY4f599GLTSjh2OCuuhdTkJQsEcZzBqbXZGKMK2OqW1oZsjtf/gQA==", "dev": true, "dependencies": { "pkg-dir": "^4.2.0", @@ -6923,9 +6911,9 @@ } }, "node_modules/is-core-module": { - "version": "2.14.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.14.0.tgz", - "integrity": "sha512-a5dFJih5ZLYlRtDc0dZWP7RiKr6xIKzmn/oAYCDvdLThadVgyJwlaoQPmRtMSpz+rk0OGAgIu+TcM9HUF0fk1A==", + "version": "2.15.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.15.0.tgz", + "integrity": "sha512-Dd+Lb2/zvk9SKy1TGCt1wFJFo/MWBPMX5x7KcvLajWTGuomczdQX61PvY5yK6SVACwpoexWo81IfFyoKY2QnTA==", "dev": true, "dependencies": { "hasown": "^2.0.2" @@ -7908,9 +7896,9 @@ } }, "node_modules/node-releases": { - "version": "2.0.14", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.14.tgz", - "integrity": "sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw==", + "version": "2.0.18", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.18.tgz", + "integrity": "sha512-d9VeXT4SJ7ZeOqGX6R5EM022wpL+eWPooLI+5UpWn2jCT1aosUQEhQP214x33Wkwx3JQMvIm+tIoVOdodFS40g==", "dev": true }, "node_modules/normalize-path": { @@ -8042,23 +8030,6 @@ "node": ">= 0.4" } }, - "node_modules/object.hasown": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/object.hasown/-/object.hasown-1.1.4.tgz", - "integrity": "sha512-FZ9LZt9/RHzGySlBARE3VF+gE26TxR38SdmqOqliuTnl9wrKulaQs+4dee1V+Io8VfxqzAfHu6YuRgUy8OHoTg==", - "dev": true, - "dependencies": { - "define-properties": "^1.2.1", - "es-abstract": "^1.23.2", - "es-object-atoms": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/object.pick": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", @@ -9460,6 +9431,16 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/string.prototype.repeat": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/string.prototype.repeat/-/string.prototype.repeat-1.0.0.tgz", + "integrity": "sha512-0u/TldDbKD8bFCQ/4f5+mNRrXwZ8hg2w7ZR8wa16e8z9XpePWl3eGEcUD0OXpEH/VJH/2G3gjUtR3ZOiBe2S/w==", + "dev": true, + "dependencies": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.5" + } + }, "node_modules/string.prototype.trim": { "version": "1.2.9", "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.9.tgz", @@ -9621,9 +9602,9 @@ } }, "node_modules/terser": { - "version": "5.31.2", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.31.2.tgz", - "integrity": "sha512-LGyRZVFm/QElZHy/CPr/O4eNZOZIzsrQ92y4v9UJe/pFJjypje2yI3C2FmPtvUEnhadlSbmG2nXtdcjHOjCfxw==", + "version": "5.31.3", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.31.3.tgz", + "integrity": "sha512-pAfYn3NIZLyZpa83ZKigvj6Rn9c/vd5KfYGX7cN1mnzqgDcxWvrU5ZtAfIKhEXz9nRecw4z3LXkjaq96/qZqAA==", "dev": true, "dependencies": { "@jridgewell/source-map": "^0.3.3", @@ -9924,9 +9905,9 @@ "dev": true }, "node_modules/uglify-js": { - "version": "3.18.0", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.18.0.tgz", - "integrity": "sha512-SyVVbcNBCk0dzr9XL/R/ySrmYf0s372K6/hFklzgcp2lBFyXtw4I7BOdDjlLhE1aVqaI/SHWXWmYdlZxuyF38A==", + "version": "3.19.0", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.0.tgz", + "integrity": "sha512-wNKHUY2hYYkf6oSFfhwwiHo4WCHzHmzcXsqXYTN9ja3iApYIFbb2U6ics9hBcYLHcYGQoAlwnZlTrf3oF+BL/Q==", "dev": true, "bin": { "uglifyjs": "bin/uglifyjs" @@ -10747,8 +10728,9 @@ }, "node_modules/wp-rocket-scripts": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/wp-rocket-scripts/-/wp-rocket-scripts-1.0.1.tgz", - "integrity": "sha512-GZyqgCOo2fjMeNfuHDZ3B1ZH2UgeCoI8/Ts9vJbIXxuvSunF+lE+3tLhSfyDnM416KMa23u13S29i8eZ1CR82g==" + "resolved": "git+ssh://git@github.com/wp-media/rocket-scripts.git#c18c2ee25b531f8109e9f03bbdc7c5bb07d35551", + "dev": true, + "license": "ISC" }, "node_modules/wrap-ansi": { "version": "7.0.0", @@ -10892,27 +10874,27 @@ } }, "@babel/compat-data": { - "version": "7.24.8", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.24.8.tgz", - "integrity": "sha512-c4IM7OTg6k1Q+AJ153e2mc2QVTezTwnb4VzquwcyiEzGnW0Kedv4do/TrkU98qPeC5LNiMt/QXwIjzYXLBpyZg==", + "version": "7.24.9", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.24.9.tgz", + "integrity": "sha512-e701mcfApCJqMMueQI0Fb68Amflj83+dvAvHawoBpAz+GDjCIyGHzNwnefjsWJ3xiYAqqiQFoWbspGYBdb2/ng==", "dev": true }, "@babel/core": { - "version": "7.24.8", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.24.8.tgz", - "integrity": "sha512-6AWcmZC/MZCO0yKys4uhg5NlxL0ESF3K6IAaoQ+xSXvPyPyxNWRafP+GDbI88Oh68O7QkJgmEtedWPM9U0pZNg==", + "version": "7.24.9", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.24.9.tgz", + "integrity": "sha512-5e3FI4Q3M3Pbr21+5xJwCv6ZT6KmGkI0vw3Tozy5ODAQFTIWe37iT8Cr7Ice2Ntb+M3iSKCEWMB1MBgKrW3whg==", "dev": true, "requires": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.24.7", - "@babel/generator": "^7.24.8", + "@babel/generator": "^7.24.9", "@babel/helper-compilation-targets": "^7.24.8", - "@babel/helper-module-transforms": "^7.24.8", + "@babel/helper-module-transforms": "^7.24.9", "@babel/helpers": "^7.24.8", "@babel/parser": "^7.24.8", "@babel/template": "^7.24.7", "@babel/traverse": "^7.24.8", - "@babel/types": "^7.24.8", + "@babel/types": "^7.24.9", "convert-source-map": "^2.0.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", @@ -10932,12 +10914,12 @@ } }, "@babel/generator": { - "version": "7.24.8", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.24.8.tgz", - "integrity": "sha512-47DG+6F5SzOi0uEvK4wMShmn5yY0mVjVJoWTphdY2B4Rx9wHgjK7Yhtr0ru6nE+sn0v38mzrWOlah0p/YlHHOQ==", + "version": "7.24.10", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.24.10.tgz", + "integrity": "sha512-o9HBZL1G2129luEUlG1hB4N/nlYNWHnpwlND9eOMclRqqu1YDy2sSYVCFUZwl8I1Gxh+QSRrP2vD7EpUmFVXxg==", "dev": true, "requires": { - "@babel/types": "^7.24.8", + "@babel/types": "^7.24.9", "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.25", "jsesc": "^2.5.1" @@ -11065,9 +11047,9 @@ } }, "@babel/helper-module-transforms": { - "version": "7.24.8", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.24.8.tgz", - "integrity": "sha512-m4vWKVqvkVAWLXfHCCfff2luJj86U+J0/x+0N3ArG/tP0Fq7zky2dYwMbtPmkc/oulkkbjdL3uWzuoBwQ8R00Q==", + "version": "7.24.9", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.24.9.tgz", + "integrity": "sha512-oYbh+rtFKj/HwBQkFlUzvcybzklmVdVV3UU+mN7n2t/q3yGHbuVdNxyFvSBO1tfvjyArpHNcWMAzsSPdyI46hw==", "dev": true, "requires": { "@babel/helper-environment-visitor": "^7.24.7", @@ -12121,9 +12103,9 @@ } }, "@babel/types": { - "version": "7.24.8", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.24.8.tgz", - "integrity": "sha512-SkSBEHwwJRU52QEVZBmMBnE5Ux2/6WU1grdYyOhpbCNxbmJrDuDCphBzKZSO3taf0zztp+qkWlymE5tVL5l0TA==", + "version": "7.24.9", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.24.9.tgz", + "integrity": "sha512-xm8XrMKz0IlUdocVbYJe0Z9xEgidU7msskG8BbhnTPK/HZ2z/7FP7ykqPgrUH+C+r414mNfNWam1f2vqOjqjYQ==", "dev": true, "requires": { "@babel/helper-string-parser": "^7.24.8", @@ -12375,9 +12357,9 @@ } }, "@types/eslint": { - "version": "8.56.10", - "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.10.tgz", - "integrity": "sha512-Shavhk87gCtY2fhXDctcfS3e6FdxWkCx1iUZ9eEUbh7rTqlZT0/IzOkCOVt0fCjcFuZ9FPYfuezTBImfHCDBGQ==", + "version": "9.6.0", + "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-9.6.0.tgz", + "integrity": "sha512-gi6WQJ7cHRgZxtkQEoyHMppPjq9Kxo5Tjn2prSKDSmZrCz8TZ3jSRCeTJm+WoM+oB0WG37bRqLzaaU3q7JypGg==", "dev": true, "requires": { "@types/estree": "*", @@ -12413,9 +12395,9 @@ "dev": true }, "@types/node": { - "version": "20.14.10", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.10.tgz", - "integrity": "sha512-MdiXf+nDuMvY0gJKxyfZ7/6UFsETO7mGKF54MVD/ekJS6HdFtpZFBgrh6Pseu64XTb2MLyFPlbW6hj8HYRQNOQ==", + "version": "20.14.11", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.11.tgz", + "integrity": "sha512-kprQpL8MMeszbz6ojB5/tU8PLN4kesnN8Gjzw349rDlNgsSzg90lAVj3llK99Dh7JON+t9AuscPPFW6mPbTnSA==", "dev": true, "requires": { "undici-types": "~5.26.4" @@ -12818,18 +12800,6 @@ "es-shim-unscopables": "^1.0.0" } }, - "array.prototype.toreversed": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/array.prototype.toreversed/-/array.prototype.toreversed-1.1.2.tgz", - "integrity": "sha512-wwDCoT4Ck4Cz7sLtgUmzR5UV3YF5mFHUlbChCzZBQZ+0m2cl/DH3tKgvphv1nKgFsJ48oCSg6p91q2Vm0I/ZMA==", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "define-properties": "^1.2.0", - "es-abstract": "^1.22.1", - "es-shim-unscopables": "^1.0.0" - } - }, "array.prototype.tosorted": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/array.prototype.tosorted/-/array.prototype.tosorted-1.1.4.tgz", @@ -13986,9 +13956,9 @@ "dev": true }, "caniuse-lite": { - "version": "1.0.30001641", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001641.tgz", - "integrity": "sha512-Phv5thgl67bHYo1TtMY/MurjkHhV4EDaCosezRXgZ8jzA/Ub+wjxAvbGvjoFENStinwi5kCyOYV3mi5tOGykwA==", + "version": "1.0.30001643", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001643.tgz", + "integrity": "sha512-ERgWGNleEilSrHM6iUz/zJNSQTP8Mr21wDWpdgvRwcTXGAq6jMtOUPP4dqFPTdKqZ2wKTdtB+uucZ3MRpAUSmg==", "dev": true }, "chalk": { @@ -14557,15 +14527,15 @@ } }, "electron-to-chromium": { - "version": "1.4.827", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.827.tgz", - "integrity": "sha512-VY+J0e4SFcNfQy19MEoMdaIcZLmDCprqvBtkii1WTCTQHpRvf5N8+3kTYCgL/PcntvwQvmMJWTuDPsq+IlhWKQ==", + "version": "1.4.833", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.833.tgz", + "integrity": "sha512-aVGP9xK70Ysrzip1m5LoJjCp1EDrYzZ7Pg/O3QR1h3PAhmc8SNfSXV3kmmtkg5rNO42EcTYmLX3eFMgqALlGIA==", "dev": true }, "elliptic": { - "version": "6.5.5", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.5.tgz", - "integrity": "sha512-7EjbcmUm17NQFu4Pmgmq2olYMj8nwMnpcddByChSUjArp8F5DQWcIcpriwO4ZToLNAJig0yiyjswfyGNje/ixw==", + "version": "6.5.6", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.6.tgz", + "integrity": "sha512-mpzdtpeCLuS3BmE3pO3Cpp5bbjlOPY2Q0PgoF+Od1XZrHLYI28Xe3ossCmYCQt11FQKEYd9+PF8jymTvtWJSHQ==", "dev": true, "requires": { "bn.js": "^4.11.9", @@ -15032,29 +15002,29 @@ } }, "eslint-plugin-react": { - "version": "7.34.3", - "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.34.3.tgz", - "integrity": "sha512-aoW4MV891jkUulwDApQbPYTVZmeuSyFrudpbTAQuj5Fv8VL+o6df2xIGpw8B0hPjAaih1/Fb0om9grCdyFYemA==", + "version": "7.35.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.35.0.tgz", + "integrity": "sha512-v501SSMOWv8gerHkk+IIQBkcGRGrO2nfybfj5pLxuJNFTPxxA3PSryhXTK+9pNbtkggheDdsC0E9Q8CuPk6JKA==", "dev": true, "requires": { "array-includes": "^3.1.8", "array.prototype.findlast": "^1.2.5", "array.prototype.flatmap": "^1.3.2", - "array.prototype.toreversed": "^1.1.2", "array.prototype.tosorted": "^1.1.4", "doctrine": "^2.1.0", "es-iterator-helpers": "^1.0.19", "estraverse": "^5.3.0", + "hasown": "^2.0.2", "jsx-ast-utils": "^2.4.1 || ^3.0.0", "minimatch": "^3.1.2", "object.entries": "^1.1.8", "object.fromentries": "^2.0.8", - "object.hasown": "^1.1.4", "object.values": "^1.2.0", "prop-types": "^15.8.1", "resolve": "^2.0.0-next.5", "semver": "^6.3.1", - "string.prototype.matchall": "^4.0.11" + "string.prototype.matchall": "^4.0.11", + "string.prototype.repeat": "^1.0.0" }, "dependencies": { "doctrine": { @@ -16046,9 +16016,9 @@ "dev": true }, "immutable": { - "version": "4.3.6", - "resolved": "https://registry.npmjs.org/immutable/-/immutable-4.3.6.tgz", - "integrity": "sha512-Ju0+lEMyzMVZarkTn/gqRpdqd5dOPaz1mCZ0SH3JV6iFw81PldE/PEB1hWVEA288HPt4WXW8O7AWxB10M+03QQ==", + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/immutable/-/immutable-4.3.7.tgz", + "integrity": "sha512-1hqclzwYwjRDFLjcFxOM5AYkkG0rpFPpr1RLPMEuGczoS7YA8gLhy8SWXYRAA/XwfEHpfo3cw5JGioS32fnMRw==", "dev": true }, "import-fresh": { @@ -16062,9 +16032,9 @@ } }, "import-local": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.1.0.tgz", - "integrity": "sha512-ASB07uLtnDs1o6EHjKpX34BKYDSqnFerfTOJL2HvMqF70LnxpjkzDB8J44oT9pu4AMPkQwf8jl6szgvNd2tRIg==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.2.0.tgz", + "integrity": "sha512-2SPlun1JUPWoM6t3F0dw0FkCF/jWY8kttcY4f599GLTSjh2OCuuhdTkJQsEcZzBqbXZGKMK2OqW1oZsjtf/gQA==", "dev": true, "requires": { "pkg-dir": "^4.2.0", @@ -16232,9 +16202,9 @@ "dev": true }, "is-core-module": { - "version": "2.14.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.14.0.tgz", - "integrity": "sha512-a5dFJih5ZLYlRtDc0dZWP7RiKr6xIKzmn/oAYCDvdLThadVgyJwlaoQPmRtMSpz+rk0OGAgIu+TcM9HUF0fk1A==", + "version": "2.15.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.15.0.tgz", + "integrity": "sha512-Dd+Lb2/zvk9SKy1TGCt1wFJFo/MWBPMX5x7KcvLajWTGuomczdQX61PvY5yK6SVACwpoexWo81IfFyoKY2QnTA==", "dev": true, "requires": { "hasown": "^2.0.2" @@ -16966,9 +16936,9 @@ } }, "node-releases": { - "version": "2.0.14", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.14.tgz", - "integrity": "sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw==", + "version": "2.0.18", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.18.tgz", + "integrity": "sha512-d9VeXT4SJ7ZeOqGX6R5EM022wpL+eWPooLI+5UpWn2jCT1aosUQEhQP214x33Wkwx3JQMvIm+tIoVOdodFS40g==", "dev": true }, "normalize-path": { @@ -17061,17 +17031,6 @@ "es-abstract": "^1.23.2" } }, - "object.hasown": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/object.hasown/-/object.hasown-1.1.4.tgz", - "integrity": "sha512-FZ9LZt9/RHzGySlBARE3VF+gE26TxR38SdmqOqliuTnl9wrKulaQs+4dee1V+Io8VfxqzAfHu6YuRgUy8OHoTg==", - "dev": true, - "requires": { - "define-properties": "^1.2.1", - "es-abstract": "^1.23.2", - "es-object-atoms": "^1.0.0" - } - }, "object.pick": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", @@ -18151,6 +18110,16 @@ "side-channel": "^1.0.6" } }, + "string.prototype.repeat": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/string.prototype.repeat/-/string.prototype.repeat-1.0.0.tgz", + "integrity": "sha512-0u/TldDbKD8bFCQ/4f5+mNRrXwZ8hg2w7ZR8wa16e8z9XpePWl3eGEcUD0OXpEH/VJH/2G3gjUtR3ZOiBe2S/w==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.5" + } + }, "string.prototype.trim": { "version": "1.2.9", "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.9.tgz", @@ -18270,9 +18239,9 @@ } }, "terser": { - "version": "5.31.2", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.31.2.tgz", - "integrity": "sha512-LGyRZVFm/QElZHy/CPr/O4eNZOZIzsrQ92y4v9UJe/pFJjypje2yI3C2FmPtvUEnhadlSbmG2nXtdcjHOjCfxw==", + "version": "5.31.3", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.31.3.tgz", + "integrity": "sha512-pAfYn3NIZLyZpa83ZKigvj6Rn9c/vd5KfYGX7cN1mnzqgDcxWvrU5ZtAfIKhEXz9nRecw4z3LXkjaq96/qZqAA==", "dev": true, "requires": { "@jridgewell/source-map": "^0.3.3", @@ -18495,9 +18464,9 @@ "dev": true }, "uglify-js": { - "version": "3.18.0", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.18.0.tgz", - "integrity": "sha512-SyVVbcNBCk0dzr9XL/R/ySrmYf0s372K6/hFklzgcp2lBFyXtw4I7BOdDjlLhE1aVqaI/SHWXWmYdlZxuyF38A==", + "version": "3.19.0", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.0.tgz", + "integrity": "sha512-wNKHUY2hYYkf6oSFfhwwiHo4WCHzHmzcXsqXYTN9ja3iApYIFbb2U6ics9hBcYLHcYGQoAlwnZlTrf3oF+BL/Q==", "dev": true }, "umd": { @@ -19117,9 +19086,9 @@ "dev": true }, "wp-rocket-scripts": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/wp-rocket-scripts/-/wp-rocket-scripts-1.0.1.tgz", - "integrity": "sha512-GZyqgCOo2fjMeNfuHDZ3B1ZH2UgeCoI8/Ts9vJbIXxuvSunF+lE+3tLhSfyDnM416KMa23u13S29i8eZ1CR82g==" + "version": "git+ssh://git@github.com/wp-media/rocket-scripts.git#c18c2ee25b531f8109e9f03bbdc7c5bb07d35551", + "dev": true, + "from": "wp-rocket-scripts@github:wp-media/rocket-scripts#refactor-beacon-before-wpr-3.17" }, "wrap-ansi": { "version": "7.0.0", diff --git a/package.json b/package.json index 074cbc60d6..9d2752c6f8 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "watchify": "^4.0.0", "webpack": "^5.76.0", "webpack-cli": "^4.9.1", - "wp-rocket-scripts": "^1.0.1", + "wp-rocket-scripts": "github:wp-media/rocket-scripts#refactor-beacon-before-wpr-3.17", "yargs": "^17.3.0" } } From 9eedcee20bb1570d1f3d61f5d11289e4dfe26763 Mon Sep 17 00:00:00 2001 From: WordPressFan Date: Tue, 23 Jul 2024 10:17:56 +0300 Subject: [PATCH 10/13] update gulp task for building all scripts --- src/js/gulp/tasks/js.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/js/gulp/tasks/js.js b/src/js/gulp/tasks/js.js index 8443b88fc3..0d43613efe 100644 --- a/src/js/gulp/tasks/js.js +++ b/src/js/gulp/tasks/js.js @@ -64,8 +64,7 @@ class gulpJs { () => this.buildAppUnmin(), () => this.buildAppMin(), () => this.buildLazyloadCssMin(), - () => this.buildLcpBeaconUnMin(), - () => this.buildLcpBeaconMin() + () => this.buildLcpBeacon() ); } From bbdf639d2da9fd5a8812a726d322cc07af3da08a Mon Sep 17 00:00:00 2001 From: WordPressFan Date: Tue, 23 Jul 2024 13:36:22 +0300 Subject: [PATCH 11/13] update gulp task name to be beacon instead of lcp --- README.md | 30 +++++++++++++++--------------- gulpfile.js | 2 +- src/js/gulp/gulpconfig.js | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index ba8d5bf40a..aa21ea9a08 100644 --- a/README.md +++ b/README.md @@ -32,21 +32,21 @@ To be able to validate your license and use the plugin, you will also have to ma ## Gulp Tasks -| Command | Description | -|--------------------------------|:--------------------------------------------------------------------------------------------------------------------------------:| -| **CSS Tasks** | | -| `gulp build:saas:unmin` | Builds Full admin CSS, the unminified version (wpr-admin.css) | -| `gulp build:saas:min` | Builds Full admin CSS, the minified version (wpr-admin.min.css) | -| `gulp build:sass:all` | Builds all admin CSS files (wpr-admin.css, wpr-admin.min.css, wpr-admin-rtl.css, wpr-admin-rtl.min.css) | -| `gulp sass:watch` | Watches all admin CSS files mentioned above and builds them again with any change. | -| **JS Tasks** | | -| `gulp build:js:app:unmin` | Builds admin app js file, the unminified version (wpr-admin.js) | -| `gulp build:js:app:min` | Builds admin app js file, the minified version (wpr-admin.min.js) | -| `gulp build:js:lazyloadcss:min` | Builds lazyload CSS js file, the minified version (lazyload-css.min.js) | -| `gulp build:js:lcp` | Builds lcp beacon script, the minified version (lcp-beacon.min.js, source file, and map file) | -| `gulp build:js:all` | Builds all js files mentioned above (wpr-admin.js, wpr-admin.min.js, lazyload-css.min.js, lcp-beacon) | -| `gulp build:js:lcp` | Builds lcp beacon script, the minified version (wpr-beacon.min.js, source file, and map file) | -| `gulp js:watch` | Watches all js files changes and build them again with any change. | +| Command | Description | +|---------------------------------|:-------------------------------------------------------------------------------------------------------:| +| **CSS Tasks** | | +| `gulp build:saas:unmin` | Builds Full admin CSS, the unminified version (wpr-admin.css) | +| `gulp build:saas:min` | Builds Full admin CSS, the minified version (wpr-admin.min.css) | +| `gulp build:sass:all` | Builds all admin CSS files (wpr-admin.css, wpr-admin.min.css, wpr-admin-rtl.css, wpr-admin-rtl.min.css) | +| `gulp sass:watch` | Watches all admin CSS files mentioned above and builds them again with any change. | +| **JS Tasks** | | +| `gulp build:js:app:unmin` | Builds admin app js file, the unminified version (wpr-admin.js) | +| `gulp build:js:app:min` | Builds admin app js file, the minified version (wpr-admin.min.js) | +| `gulp build:js:lazyloadcss:min` | Builds lazyload CSS js file, the minified version (lazyload-css.min.js) | +| `gulp build:js:lcp` | Builds lcp beacon script, the minified version (lcp-beacon.min.js, source file, and map file) | +| `gulp build:js:all` | Builds all js files mentioned above (wpr-admin.js, wpr-admin.min.js, lazyload-css.min.js, wpr-beacon) | +| `gulp build:js:beacon` | Builds beacon script (wpr-beacon.min.js, source file, and map file) | +| `gulp js:watch` | Watches all js files changes and build them again with any change. | ## Support diff --git a/gulpfile.js b/gulpfile.js index b721ded0bb..d69d1294b2 100755 --- a/gulpfile.js +++ b/gulpfile.js @@ -18,7 +18,7 @@ requireDir('./src/js/gulp/tasks', { recurse: true }); * gulp build:js:app:min => Builds admin app js file, the minified version (wpr-admin.min.js) * gulp build:js:lazyloadcss:min => Builds lazyload CSS js file, the minified version (lazyload-css.min.js) * gulp build:js:all => Builds all js files mentioned above (wpr-admin.js, wpr-admin.min.js, lazyload-css.min.js, wpr-beacon.min.js) -* gulp build:js:lcp => Builds lcp beacon script, the minified version (wpr-beacon.min.js, source file, and map file) +* gulp build:js:beacon => Builds lcp beacon script, the minified version (wpr-beacon.min.js, source file, and map file) * gulp js:watch => Watches all js files changes and build them again with any change. * */ diff --git a/src/js/gulp/gulpconfig.js b/src/js/gulp/gulpconfig.js index c5c26937e8..a26a242e16 100644 --- a/src/js/gulp/gulpconfig.js +++ b/src/js/gulp/gulpconfig.js @@ -34,7 +34,7 @@ module.exports = { }, { - task: 'build:js:lcp', + task: 'build:js:beacon', method: 'buildLcpBeacon', }, From e4e4140c8bee100cd983ccfa3fc9978ef0a473aa Mon Sep 17 00:00:00 2001 From: WordPressFan Date: Tue, 23 Jul 2024 16:56:55 +0300 Subject: [PATCH 12/13] use the correct package version --- package-lock.json | 29 +++++++++++++++-------------- package.json | 2 +- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index 49e41f066c..68aebb1960 100644 --- a/package-lock.json +++ b/package-lock.json @@ -43,7 +43,7 @@ "watchify": "^4.0.0", "webpack": "^5.76.0", "webpack-cli": "^4.9.1", - "wp-rocket-scripts": "github:wp-media/rocket-scripts#refactor-beacon-before-wpr-3.17", + "wp-rocket-scripts": "^1.0.2-alpha", "yargs": "^17.3.0" } }, @@ -4739,9 +4739,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.833", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.833.tgz", - "integrity": "sha512-aVGP9xK70Ysrzip1m5LoJjCp1EDrYzZ7Pg/O3QR1h3PAhmc8SNfSXV3kmmtkg5rNO42EcTYmLX3eFMgqALlGIA==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.0.tgz", + "integrity": "sha512-Vb3xHHYnLseK8vlMJQKJYXJ++t4u1/qJ3vykuVrVjvdiOEhYyT1AuP4x03G8EnPmYvYOhe9T+dADTmthjRQMkA==", "dev": true }, "node_modules/elliptic": { @@ -10727,10 +10727,10 @@ } }, "node_modules/wp-rocket-scripts": { - "version": "1.0.1", - "resolved": "git+ssh://git@github.com/wp-media/rocket-scripts.git#c18c2ee25b531f8109e9f03bbdc7c5bb07d35551", - "dev": true, - "license": "ISC" + "version": "1.0.2-alpha", + "resolved": "https://registry.npmjs.org/wp-rocket-scripts/-/wp-rocket-scripts-1.0.2-alpha.tgz", + "integrity": "sha512-LnP09lxaTDkXef1Wi6+1syqmFsGGk6V982uvliILBJwA8OeBY4zWHAOh/NFIiBcKOkiYYoA+u30Q2xuAF3nvsw==", + "dev": true }, "node_modules/wrap-ansi": { "version": "7.0.0", @@ -14527,9 +14527,9 @@ } }, "electron-to-chromium": { - "version": "1.4.833", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.833.tgz", - "integrity": "sha512-aVGP9xK70Ysrzip1m5LoJjCp1EDrYzZ7Pg/O3QR1h3PAhmc8SNfSXV3kmmtkg5rNO42EcTYmLX3eFMgqALlGIA==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.0.tgz", + "integrity": "sha512-Vb3xHHYnLseK8vlMJQKJYXJ++t4u1/qJ3vykuVrVjvdiOEhYyT1AuP4x03G8EnPmYvYOhe9T+dADTmthjRQMkA==", "dev": true }, "elliptic": { @@ -19086,9 +19086,10 @@ "dev": true }, "wp-rocket-scripts": { - "version": "git+ssh://git@github.com/wp-media/rocket-scripts.git#c18c2ee25b531f8109e9f03bbdc7c5bb07d35551", - "dev": true, - "from": "wp-rocket-scripts@github:wp-media/rocket-scripts#refactor-beacon-before-wpr-3.17" + "version": "1.0.2-alpha", + "resolved": "https://registry.npmjs.org/wp-rocket-scripts/-/wp-rocket-scripts-1.0.2-alpha.tgz", + "integrity": "sha512-LnP09lxaTDkXef1Wi6+1syqmFsGGk6V982uvliILBJwA8OeBY4zWHAOh/NFIiBcKOkiYYoA+u30Q2xuAF3nvsw==", + "dev": true }, "wrap-ansi": { "version": "7.0.0", diff --git a/package.json b/package.json index 9d2752c6f8..d1eb595ced 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "watchify": "^4.0.0", "webpack": "^5.76.0", "webpack-cli": "^4.9.1", - "wp-rocket-scripts": "github:wp-media/rocket-scripts#refactor-beacon-before-wpr-3.17", + "wp-rocket-scripts": "^1.0.2-alpha", "yargs": "^17.3.0" } } From 42b0a408c880a664f936803934091cb72d93fcd1 Mon Sep 17 00:00:00 2001 From: WordPressFan Date: Wed, 24 Jul 2024 14:19:47 +0300 Subject: [PATCH 13/13] remove not needed line --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index aa21ea9a08..5ed744111f 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,6 @@ To be able to validate your license and use the plugin, you will also have to ma | `gulp build:js:app:unmin` | Builds admin app js file, the unminified version (wpr-admin.js) | | `gulp build:js:app:min` | Builds admin app js file, the minified version (wpr-admin.min.js) | | `gulp build:js:lazyloadcss:min` | Builds lazyload CSS js file, the minified version (lazyload-css.min.js) | -| `gulp build:js:lcp` | Builds lcp beacon script, the minified version (lcp-beacon.min.js, source file, and map file) | | `gulp build:js:all` | Builds all js files mentioned above (wpr-admin.js, wpr-admin.min.js, lazyload-css.min.js, wpr-beacon) | | `gulp build:js:beacon` | Builds beacon script (wpr-beacon.min.js, source file, and map file) | | `gulp js:watch` | Watches all js files changes and build them again with any change. |