Comments (2)
Bringing back to ToDo as this is not fixed: I still have errors when re-visiting the page and the LCP value in case of not found is not "not found" but null.
There are several issues:
- the beacon script sends an "image" with lcp label, even if there is no element.
To fix this, I modified "topCandidates" in the beacon by adding a filter to take out items where the getElementInfo did not find anything relevant:
const topCandidates = potentialCandidates.map(element => {
const rect = element.getBoundingClientRect();
return {
element: element,
rect: rect,
};
}).filter(item => {
return (
item.rect.width > 0 &&
item.rect.height > 0 &&
isIntersecting(item.rect)
);
})
.map(item => ({
item,
area: getArea(item.rect),
elementInfo: getElementInfo(item.element),
}))
.filter(item => {
return (
item.elementInfo !== null &&
item.elementInfo.type !== ""
);
})
.sort((a, b) => b.area - a.area)
.slice(0, count);
The issue is that, even if getElementInfo does not find anything, it returns an elementInfo with a dummy structure. Hence, the check later on const firstElementWithInfo = above_the_fold_images.find(item => item.elementInfo !== null);
seems useless! There will always be a elementInfo ; but a dummy one sometimes.
It might not be the right way to do it, but the 1st issue is here: notice that without this fix, we don't have the log "No LCP element found" on http://mathieu.e2e.rocketlabsqa.ovh/ for instance. This shows that the beacon thinks there is an LCP becasue it does not filter out empty/irrelevant elements.
- Once this is fixed, instead of null in the DB, I get
"not found"
. Be careful, the"
are actually in the string! This leads to the following warning logs:
[25-Apr-2024 16:53:58 UTC] PHP Warning: Attempt to read property "type" on string in /var/www/html/mathieu.e2e.rocketlabsqa.ovh/wp-content/plugins/wp-rocket/inc/Engine/Media/AboveTheFold/Frontend/Controller.php on line 250
[25-Apr-2024 16:53:58 UTC] PHP Warning: Attempt to read property "type" on string in /var/www/html/mathieu.e2e.rocketlabsqa.ovh/wp-content/plugins/wp-rocket/inc/Engine/Media/AboveTheFold/Frontend/Controller.php on line 143
The issue is: the check in has_lcp
$lcp !== 'not found'
is true because '"not found"' !== 'not found'
I think the additional " comes from the use of wp_json_encode
in 'lcp' => wp_json_encode( $lcp ),
two choices here: either change how we write into the DB in case $lcp = 'not found' to avoid adding the additional ", or change the has_lcp
check.
After this, it seems working as expected, without logs.
One should check this, fix and ensure the modifications don't break tests on Rocket-E2E.
from wp-rocket.
Note: other page template without images on e2e https://e2e.rocketlabsqa.ovh/lcp_no_images/
from wp-rocket.
Related Issues (20)
- LCP/ATF is not found for images loaded by ajax
- Clear critical images shouldn't be in admin bar while not having valid license
- 3.16 - Secure LCP/ATF data from the AJAX endpoint and DB HOT 2
- Commented URLs at home page shouldn't be sent to saas HOT 1
- 3.16 - When RUCSS & LCP/ATF are both enabled, URLs sent to the SaaS should have the wpr_imagedimensions=1 query string HOT 3
- 3.16 - Error & timeout handling of Beacon Script HOT 4
- Reduce the processing on not-cached page when checking the LCP/ATF data HOT 12
- Should fetch up to 10 valid (internal) links from Homepage and expand search for valid links beyond the 1st 10 if needed HOT 5
- 3.16 - Remove console.log of the beacon script when the debug mode is not enabled HOT 3
- 3.16 Preload - Shouldn't fetch RSS feed or restAPI links from the Homepage HOT 5
- In case rocket_atf_warmup_links filter is given a wrong input, the fetch mechanism should default to 10 URLs + home
- LazyLoad for CSS background images breaks linear-gradient applied to images
- Should fetch the 1st 10 links in home page on multisite HOT 3
- WPR Settings page fatal error when debug file is so large even though debug mode is disabled
- LCP/ATF Warm up process not blocked on local env
- Warmup needs to generate desktop and mobile data HOT 3
- Clear Used CSS for this URL does not appear in the post editor HOT 1
- Exploratory testing on 3.16 HOT 7
- Guard beacon script against saving not expected values into the database HOT 22
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wp-rocket.