Comments (9)
About keeping intersecting images:
The issue comes from the beacon script in the LCPCandidates
: https://github.com/wp-media/wp-rocket/blob/b459f191a348426b2b1a3cf656a4db577e76800f/assets/js/lcp-beacon.js#L9C1-L16C12
This condition is checking that the image is fully in the viewport. Instead, we should check that it is intersecting only. We have such a check already for the ATF images here.
- We should make a dedicated function
isIntersecting(rect)
returning a boolean based on the check already existing, and use this in both here and here.
About accounting only for the visible area for LCP "score"
The area to account for is computed here. It is currently accounting for the complete image size.
To account for the visible part only, we should do:
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))
const area = visibleWidth * visibleHeight;
For the testing part, TBC with @jeawhanlee but it might be more suited to test this with Rocket-E2E.
Effort: [XS] (test scenarios are outside the scope as they are already on Rocket-E2E, if we will use Rocket-E2E).
from wp-rocket.
Should this be moved to Ready for Review?
from wp-rocket.
@Miraeld @wp-media/qa-team Do we have test scenarios, maybe on Rocket-E2E to validate this? Maybe similar to the acceptance criteria?
from wp-rocket.
@MathieuLamiot not from what I am aware of.
from wp-rocket.
@MathieuLamiot , @Miraeld just pushed these 2 templates on /wp-media/rocket-test-data:
lcp_images_intersecting_viewport_A.php
lcp_images_intersecting_viewport_B.php
that should cover the AC.
Will provide you with pages created on e2e as well, in a moment.
from wp-rocket.
@MathieuLamiot , @Miraeld
on e2e, scenario 1
ImageA (size: 200x200, fully in the viewport) and ImageB (size:300x300, only 300x1 visible in the viewport)
we have page link)
and for scenario 2
ImageA (size: 200x200, fully in the viewport) and ImageB (size:300x300, only 300x250 visible in the viewport)
we have page link
TC link.
from wp-rocket.
@Miraeld Have you performed basic checks to ensure the code does not break on happy path and that the reported failing cases are fixed? In which case, we can merge so that we only have to work on the feature branch. OK? Thanks 🙏
from wp-rocket.
Kind reminder @Miraeld: can this be merged?
from wp-rocket.
I did basic check yea, and it worked.
I think it can be merged yes.
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 HOT 2
- Warmup needs to generate desktop and mobile data HOT 3
- LCP/ATF data is malformed when no LCP is found by the beacon HOT 2
- 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.