-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Largest element with a background-image that is not kept (such as linear-gradient) makes the OCI optimization have no LCP #6728
Largest element with a background-image that is not kept (such as linear-gradient) makes the OCI optimization have no LCP #6728
Comments
LCP elements should only be considered if there is an actual image on it. It's safe to skip to the next candidate if only the gradient is declared. The element will still be a valid LCP if a gradient + an image is being used. Example:
We should still reference |
I really need this issue to be fixed. Any idea when this can be expected? |
@MathieuLamiot Wouldn't it be related? |
A little bit. 6599 can make the LCP field being empty. This issue is to fallback on another LCP candidate in that case. |
Any updates? I am in dire need of having this fixed! |
@piotrbak can we bump the priority on this one? I'm seeing more page builders/themes affected by this behavior. |
I signed up for WP Rocket only recently, only to discover that this is a crucial issue holding back my site's LCP problem. Would you please share the projected ETA for this bugfix? |
Hi, I cannot access that site. If not, would someone please provide an ETA? |
We should make sure that #6995 is fixed while fixing this one. |
Reproduce the problemTo reproduce the issue, refer to #6995 as it explains how to trigger the issue. Identify the root causeThe issue is that the Scope a solutionTo solve the issue, we must update the if (element_info.bg_set.length <= 0) {
return null;
} This change ensures that elements with only gradients are evicted by checking if the Also, we should change this line within const firstElementWithInfo = elements.find(item => {
return item.elementInfo !== null && (item.elementInfo.src || item.elementInfo.srcset);
}); in order to ensure that the Development steps
Effort estimationS |
LGTM |
Related Test Plan HERE. |
…#33) * fixed lcp background image 🐛 :closes: wp-media/wp-rocket#6728 * Add tests * Improve test coverage
Context
The issue is reported here: https://wp-media.slack.com/archives/C072P5EU5DF/p1718772180824549
Checking with WPR Inspector, I can see the beacon returns this to AJAX:
I added a JS file identical to the beacon in Chrome dev tools, added a log of
firstElementWithInfo
and found the LCP element was div.x-section.e9265-e1.m75d-0.m75d-1.hero-section.It is indeed the largest element with a background-image.
But the background image is
linear-gradient(164deg, rgb(0, 0, 0) 0%, rgb(0, 65, 85) 53%, rgb(35, 213, 171) 97%)
which is not kept in theelse
branch of_getElementInfo
(I think it does not passes the regex there).As a result, the method
_getElementInfo
returns an element with an elementInfo, but it is empty. This empty element takes the place of LCP.Expected behavior
TBC with Product team: I think we don't want to account for linear-gradient and instead, pick the next element as LCP. Is this correct?
Acceptance Criteria
TBC with Product team.
Additional information
If we want to skip elements with a background-image that is set but not as expected currently (for instance linaer-gradient), then I as able to get this behavior by just adding:
in
_getElementInfo
just beforeif (element_info.bg_set.length > 0) {
The text was updated successfully, but these errors were encountered: