-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve rendering performance with content-visibility #1308
Comments
|
Please add this CSS at least for basic WordPress themes |
@tunyk How do you see it being used in themes? I believe this would be most effective when |
I agree, in the context of standard themes. But if we are talking about all themes, then you should take into account that many of them use infinite scroll and Ajax. |
@tunyk So how do you see this being applied? In order to apply |
There is no clear-cut solution here. Theoretically (depending on the implementation of infinite scrolling), the Speculative API may also be involved here. |
For reference, I put together an example of the impact that Disabled: PageSpeed Insights For both mobile and desktop, the LCP is degraded when using |
Oh, the degraded LCP may be because I included #post-1241 {
content-visibility: auto;
contain-intrinsic-size: auto 846px;
} This results in lazy rendering of the first (sticky) post which is in the initial viewport. Lazy loading (or rendering) anything in the initial viewport is a performance anti-pattern. I'll remove that and re-test. |
I ran the following script to get the median metrics of 50 responses each with and without number=50
npm run research -- benchmark-web-vitals -u "https://content-visibility-perf-test.instawp.xyz/" -n $number -o csv -e "Moto G4" | tee mobile-without-cv.csv
npm run research -- benchmark-web-vitals -u "https://content-visibility-perf-test.instawp.xyz/?try-content-visibility=1" -n $number -o csv -e "Moto G4" | tee mobile-with-cv.csv
npm run research -- benchmark-web-vitals -u "https://content-visibility-perf-test.instawp.xyz/" -n $number -o csv -w "desktop" | tee desktop-without-cv.csv
npm run research -- benchmark-web-vitals -u "https://content-visibility-perf-test.instawp.xyz/?try-content-visibility=1" -n $number -o csv -w "desktop" | tee desktop-with-cv.csv Raw outputfor file in $(ls -r *.csv); do echo "# $file"; cat $file; echo; done
Reduction in LCP-TTFB:
Now we're getting somewhere! |
Granted, the test page is much heavier than the average webpage (er, >40x larger than the median webpage). But this is the first time I've seen proof of |
Could you please update your WordPress and theme version? That way the comparison will be more accurate. |
I just updated them. However, I don't see how this will make the comparison more accurate. It's still just testing the impact of |
I've created a POC plugin which implements The plugin collects the initial @media screen and (max-width: 480px) {
#post-27 { content-visibility: auto; contain-intrinsic-size: auto 876.41925048828px; }
}
@media screen and (min-width: 783px) {
#post-27 { content-visibility: auto; contain-intrinsic-size: auto 966.296875px; }
} The initial height is captured via the I did some benchmarking with this plugin on a vanilla install which just contained this plugin active along with the Optimization Detective dependency. The site has the Twenty Twenty-One theme active. There are 10 published posts with featured images and lorem ipsum. I tested the homepage which lists the 10 excerpts of these posts and their featured images. I created the test site in LocalWP. I created a file called
I then created a script which used the #!/bin/bash
number=100
npm --silent run research -- benchmark-web-vitals --file=cv-urls.txt -n $number -e "Moto G4" -o csv | tee mobile-cv.csv
npm --silent run research -- benchmark-web-vitals --file=cv-urls.txt -n $number -w desktop -o csv | tee desktop-cv.csv Mobile results:
Desktop results:
In both cases, the TTFB is increased as expected, due to the extra server-side processing. In the case of mobile there was an overall decrease in LCP by 2.19% whereas on desktop the overall LCP increased by 3.44%. Nevertheless, in both mobile and desktop the LCP-TTFB decreased (improved) by 8.25% and 5.1%, respectively. This is the metric that matters when a full page cache is employed, as this would eliminate the TTFB penalty introduced by Optimization Detective. I did my tests in the Linux environment of an HP Dragonfly Elite Chromebook. |
I just discovered an interesting side effect of an element having a parent with {
"isLCP": false,
"isLCPCandidate": false,
"xpath": "/*[1][self::HTML]/*[2][self::BODY]/*[2][self::DIV]/*[2][self::MAIN]/*[2][self::DIV]/*[1][self::UL]/*[5][self::LI]/*[1][self::DIV]/*[2][self::DIV]/*[1][self::DIV]/*[1][self::FIGURE]/*[1][self::PICTURE]/*[2][self::IMG]",
"intersectionRatio": 0,
"intersectionRect": {
"x": 0,
"y": 0,
"width": 0,
"height": 0,
"top": 0,
"right": 0,
"bottom": 0,
"left": 0
},
"boundingClientRect": {
"x": 0,
"y": 0,
"width": 0,
"height": 0,
"top": 0,
"right": 0,
"bottom": 0,
"left": 0
}
} This makes sense, but it also causes problems because all of the images are then considered as if they are in the initial viewport by Image Prioritizer! Because of this, it is removing performance/plugins/image-prioritizer/class-image-prioritizer-img-tag-visitor.php Lines 110 to 133 in 1be4573
Optimization Detective itself may need to add a |
Feature Description
With the URL metrics gathered by Optimization Detective, it should be possible to automatically apply
content-visibility
to areas of the page to delay rendering them until they are in the viewport. This has the opportunity to improve INP.See:
The text was updated successfully, but these errors were encountered: