wp-rocket icon indicating copy to clipboard operation
wp-rocket copied to clipboard

3.17 - Frontend Subtask

Open jeawhanlee opened this issue 1 year ago • 3 comments

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-lazyrender attribute to it
  • Then remove hashes for both matched & unmatched elements.
  • Assign the modified html to a var
  • Create a method to accept this new modified html to add style to lazy render content just before the closing head tag
[data-wpr-lazyrender] {
  content-visibility: auto;
}
  • This new method will be called in the optimize method 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

jeawhanlee avatar Aug 05 '24 13:08 jeawhanlee

👋 @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 :)

MathieuLamiot avatar Aug 21 '24 08:08 MathieuLamiot

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:

Mai-Saad avatar Aug 28 '24 12:08 Mai-Saad

1st point discussed here Pending product confirmation of the expected behavior, and an issue to tackle it.

MathieuLamiot avatar Aug 28 '24 13:08 MathieuLamiot