3.17 - Frontend Subtask
Description
This is a continuation of the Frontend task here which already caters for adding hashes to eligible elements for urls that don't have LRC data in DB. So to be done after #6835
Moving forward to complete the frontend task in a case where LRC data exists in DB
In WP_Rocket\Engine\Optimization\LazyRenderContent\Frontend::Controller::optimize
- For each matched element, add
data-wpr-lazyrenderattribute to it - Then remove hashes for both matched & unmatched elements.
- Assign the modified
htmlto avar - Create a method to accept this new modified
htmlto add style to lazy render content just before the closingheadtag
[data-wpr-lazyrender] {
content-visibility: auto;
}
- This new method will be called in the
optimizemethod and the value returned back to the buffer.
Acceptance Criteria
- No LRC optimization should be initiated if url has no LRC data in DB.
- Only elements with matched DB hashes must have data-wpr-lazyrender attribute.
- Only elements with matched DB hashes must be lazy rendered. i.e having the CSS content-visiblity rule applied to them.
- No hashes should be found on elements after LRC optimizations has completed(i.e after cache has been cleared)
- There should be no call to beacon script tag in the html after LRC optimizations has completed (i.e after cache has been cleared)
Additional information
This should be done after this is completed
👋 @Tabrisrp As part of this PR, maybe you could get the occasion to improve test coverage of the frontend controller. We had a quick fix here (see Slack https://wp-media.slack.com/archives/CUT7FLHF1/p1724228398435879). Being able to change this logic without breaking any tests could be a sign that some stuff could be better covered I think :)
Using feature/lrc
- No LRC optimization should be initiated if url has no LRC data in DB. => in this case after cache clear while in DB we have LRC as
[], no optimization is applied but hashes remain, shouldn't we remove hashes in this case? @piotrbak @MathieuLamiot - Only elements with matched DB hashes must have data-wpr-lazyrender attribute. :heavy_check_mark:
- Only elements with matched DB hashes must be lazy rendered. i.e having the CSS content-visiblity rule applied to them. :heavy_check_mark:
- No hashes should be found on elements after LRC optimizations has completed(i.e after cache has been cleared) :heavy_check_mark:
- There should be no call to beacon script tag in the html after LRC optimizations has completed (i.e after cache has been cleared) :heavy_check_mark:
1st point discussed here Pending product confirmation of the expected behavior, and an issue to tackle it.