Open Miraeld opened 1 month ago
@Miraeld @jeawhanlee
A point seems missing: what happens if the user deactivate one of the feature, let's say LCR. It would be best if the script could avoid running LCR in that case. Maybe this is the intent of config.status.atf here? In which case logic must be adapted?
if (BeaconUtils.isPageCached() && ( this.config.status.atf && generated_before.lcp )) {
this.logger.logMessage('Bailing out because data is already available');
return false;
}
Or maybe the script would get this information through the check_data? (if the feature is off, check_data returns false for this feature?). If this is indeed missing, maybe add it as a dedicated GH issue?
This needs some clarifications.
For AC purposes, maybe consider adding logs in _isGeneratedBefore to get the answers? Also, we might need a first version that is not depending on the result of _isGeneratedBefore for LCR. Otherwise, we won't be able to test without the AJAX endpoints implemented, which will create too much dependencies. @Miraeld & @jeawhanlee I would suggest to clearly state in this issue that LCR must run even if _isGeneratedBefore.lcr is true ; and add in the AJAX issue that this condition must be added then.
Regarding ACs, this issue does not need any others issues right? @wp-media/qa-team @wp-media/product ACs would mostly be testign against templates as per here
I've modified the grooming according to your comment to add some precision as you did.
Also, this issue doesn't need anything else to work, technically.
It can be tested by adding some console.log
in the script itself to see outputs.
However if we want something that works from end to end, we need the AJAX endpoint to be implemented and be able to save data, like you mention.
Now we can skip this part (AJAX) by adding logs and forcing the value of _isGeneratedBefore.lcr
for testing purpose to make it run as it would in real condition.
Description
In this issue, we will implement the
RocketLrcBeacon
class within the WPR Beacon script. TheRocketLrcBeacon
class is responsible for the Lazy Render Content (LRC) feature. The class will contain methods to handle the specific logic for the LRC process, including checking if an element is in the viewport, skipping certain elements based on specific conditions, and calculating the distance of an element from the top of the viewport. The prototype code provided will serve as a basis for the implementation. Also, this new class will use the BeaconManager to run the ajax call and pre-conditions.Sub-tasks (feedbacks)
Scope a solution
BeaconLrc
file in here.BeaconLrc
here.RocketLrcBeacon
class, which will take a config object as a parameter similar to thisrun
method in theRocketLrcBeacon
class. This method will contain the main process for the LRC feature.BeaconUtils
class based on the prototype code otherwise re-use them. These methods includeisElementInViewPort
,getDepthAndDistance
,getLocationHash
,skipElement
isElementInViewport
method will check if an element is in the viewport.getLocationHash
method will get the location hash of an element.skipElement
andshouldSkipElement
methods will determine whether to skip certain elements based on specific conditions.getDepthAndDistance
method will calculate the distance of an element from the top of the viewport.XPath
from the prototype.RocketLrcBeacon
class is properly integrated with the RocketBeacon class.RocketLrcBeacon
class to ensure it works as expected.Also, a change needs to be made to
This condition needs to take into account that LRC can also be disabled, & when it is but LCP isn't, only LRC shouldn't run.
For this implementation, we should not depends on
_isGeneratedBefore.lcr === true
as a condition, as we won't be able to test if the AJAX endpoint hasn't been developed before. Please skip this condition.Additional
Prototype code:
Additional 2 - Code not tested.
BeaconLrc
should be like:And
BeaconManager
should be modified to