Comments (12)
@MathieuLamiot We need to check if this has not been addressed in @Miraeld PR
from wp-rocket.
Same happened for inline bg here https://new.rocketlabsqa.ovh/lcp_bg_inline_template and here https://new.rocketlabsqa.ovh/lcp_bg_multimage_template, https://e2e.rocketlabsqa.ovh/lcp_bg_samestyle_template, https://e2e.rocketlabsqa.ovh/lcp_bg_responsive_webkit_template
from wp-rocket.
Identify the root cause ✅
above_the_fold_images is only checking for img
unlike LCP that check for img, background-images.
var above_the_fold_images = document.querySelectorAll("img");
Scope a solution ✅
We need to extend above_the_fold_images to check for background images and not just img or we could extend the LCPCandidates
function to get above_the_fold_images, LCPCandidates already has all the images(img, background) and only the top candidates(usually 1) is used as lcp, we can used the rest of the image as ATF.
Estimate the effort ✅
[XS]
from wp-rocket.
@Miraeld wondering if this is already captured in your PR
from wp-rocket.
Umm I don't think so, as I did not modify this line
wp-rocket/assets/js/lcp-beacon.js
Line 139 in 52c5d80
from wp-rocket.
@Miraeld Shouldn't the ATf part of the beacon script be modified as well to cover the acceptance criteria related to "exclude ATf from lazyload" of the issues #6530, #6531, #6532, etc... ?
from wp-rocket.
@Mai-Saad may I know which template is used on https://new.rocketlabsqa.ovh/lcp_attributes ?
I got a lcp_attributes_template
but it's a different page. Thanks
from wp-rocket.
Moving this back to Grooming in Progress: We indeed need to change the var above_the_fold_images = document.querySelectorAll("img");
but it might not be sufficient: @Miraeld had to add a method getElementInfo
to get the src depending on the element type (it is note always image.src).
@Miraeld, can you explain with your PR how the type field is set for ATF? I don't see it set in the beacon for ATf images, and not in the AJAX endpoint either.
I suggest the following:
- Base a new branch on Gael's PR #6559
- In the beacon script, rework the LCPCandidates method so that:
if ( rect.width > 0 && rect.height > 0 && isIntersecting( rect ))
, do the same as now + push the {element, elementInfo} in aatfCandidates
array; so that we keep track of all ATF. - Make LCPCandidates return what it currently returns + the atfCandidates array. So LCPCandidates will return [filteredArray, atfCandidates]. - In the beacon script, remove:
var above_the_fold_images = document.querySelectorAll("img");
for (var i = 0; i < above_the_fold_images.length; i++) {...}
And replace it with a loop over atfCandidates, doing the same thing, except we don't need to check if intersecting
anymore and we should push in performance_images the whole elementInfo and label: "above-the-fold".
So overall, we will loop once over all elements, keep all intersecting as ATF, and the largest one as LCP. Then we would just put all this in a performance_images array to send it to the AJAX endpoint.
WDYT? Can we have a grooming in that direction?
from wp-rocket.
Hello hello,
I've made a branch enhancement/preload-background-image-atf
which is from my own branch enhancement/preload-background-image
.
However the newest includes changes for above the fold images
to be detected the same way as LCPs.
It hasn't been optimized yet, but @Khadreal said he will manage that part.
from wp-rocket.
Thanks for the update.
Moving this to in progress then.
from wp-rocket.
@Khadreal Can you summarize the specification of this issue? From what you posted here, I understand the scope of the PR evolved quite a bit compared to the original issue. This needs to be clearly explained for everyone to be able to validate, QA can think about test plans and also for Product to know how it will behave now.
Especially if there are new hooks/features, it must be communicated and update the doc as well. Thanks 🙏
from wp-rocket.
I implemented a new elements filter called rocket_above_the_fold_elements
. This filter accepts an array, allowing anyone to extend the predefined elements captured by LCP/ATF without needing to directly edit the beacon scripts. The predefined elements currently include img, video, picture, p, main, div, li, and svg
. By using this filter, you can easily add or remove elements as needed for LCP/ATF.
from wp-rocket.
Related Issues (20)
- Warmup URLs in database not matching those in WPR debug
- Mobile manual visit isnot added to ATF table when meta viewport header is missing HOT 3
- Introduce a safe function for apply_filter
- Add section to `lcp_atf_elements` HOT 7
- Image Optimization Tab Update HOT 2
- RUCSS counter/success notices are not working correctly in certain scenario
- Preload tag has incorrect markup if LCP element has at least 2 background-images among pseudo-elements HOT 4
- Disable cache clearing when product category term is updated not working (WC REST API Request)
- Enhance the way we detect the cached page for lcp beacon script HOT 1
- Correctly handle image types when preloading LCP images HOT 16
- 3.16: Hebrew letters break preload URL HOT 4
- Improve integration tests using function mock instead of HTTP short-circuit
- Enable mobile cache button is not working in some cases HOT 2
- WP-Rocket/SaaS Crawl speed too fast HOT 2
- LCP is detected with wrong href coming from a url(xxx) syntax HOT 4
- Automatically build JS/CSS assets of WP Rocket plugin on develop branch
- Optimize the way we fetch links on home page for warmup HOT 1
- ATF optimization and lazyload exclusion is not always applied when using a CDN HOT 1
- Lazyload CSS Background Images triggers DOMException errors with specific selector
- Optimize critical images compatibility with Elementor Image Carousel
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.