-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Experiment: disable per-block stylesheet to measure the impact on TTFB and LCP #48728
Conversation
This is comparing the PR vs trunk (at 666574b) using WordPress 6.2-beta4-55456 with The test was loading the homepage 300 times via this script: I'd like to try the numbers for LCP locally. |
Thank you for running these tests @oandregal, amazing results! I wonder why classic themes become faster 🤔 I just wanted to add some notes here: |
This is comparing the PR vs trunk (at f72ebec) using WordPress 6.2-beta4-55456 with WP_DEBUG and WP_SCRIPT disabled. I've used a tool by @felixarntz and others with the following configuration: Notes:
|
Disclaimer: I won't pursue this approach, this PR is just a testing ground :)
Oh, absolutely! That's why I added LCP-TTFB to our performance tests. Though, I still wanted to test our assumptions based on the data we have now.
Yeah, given the amount of time it still takes from LCP, it'd be nice if we can spend some time looking for optimizations to TTFB. However, and specifically to per-block stylesheets, I wonder if there are wins to LCP-TTFB (the time it takes in the client) we can still do. One thing that's in my mind is the way the per-block styles are generated and whether changes to that would improve performance. At the moment, we add them as an embedded stylesheet inline. Would performance improve if we create an external stylesheet instead? External stylesheets have the benefit that can be cached by browsers, for example. A solution for that would also be useful for the global styles of the site. |
One of the things I think we should pursue is to use the style-engine... Regarding the use of I still believe we can achieve a lot by inlining small assets, it's just an ongoing project that hasn't finished yet. Maybe we should restart it and try to optimize things? |
Thanks for sharing! I'll think about this. Ironically, one of the "examples in the field" they mention as following the inline approach to validate what they are saying is a WordPress site (meaning they're highlighting how global styles work) 😅
What's left here? Is there a tracking issue/conversation I can look at? Other than optimizing how that code works, the main thing I can think of is the fact that many block styles still live in CSS and are not absorbed by the global styles algorithm, see #45198 This means they are shipped even if they'll be ignored later by the styles coming from |
@felixarntz following the conversations we had at https://core.trac.wordpress.org/ticket/57648 and GoogleChromeLabs/wpp-research#40 (comment) I've tried 3 approaches for measuring the changes in this PR:
While they show different base data (e.g. TTFB for TT1 theme: 32.7ms vs 74.79ms vs 75.40ms), they essentially report the same variance between themes or changes. One thing I've noticed is that the benchmark-web-vitals script seems to have better "stability". The results for classic themes in this experiment are not expected to change, and the variance reported by each one was:
I've been frustrated by how the curl approach report so small numbers (15ms for classic and 30ms for block themes in some configuration of my laptopt), which makes it difficult to find smaller changes that affect performance. benchmark-web-vitals is really nice and if it adds LCP-TTFB it can become my tool of choice for this sort of testing! |
Closing this PR, as I consider the experiment finished: separating assets is still relevant for performance, and our metrics reflect that. Conversation can continue, though :) |
Looking at the dev note shared when rolling out per-block (it applies to core blocks) stylesheet, I was wondering whether the part that inlines CSS styles has the biggest impact here:
That's the part that is probably the heaviest computation wise and it also impacts the size of the HTML document sent to users. So maybe another test would be useful here but instead of disabling granular serving of styles for core blocks, we could check different thresholds for inlining styles (applies to all blocks): add_filter( 'styles_inline_size_limit', '__return_zero' ); add_filter( 'styles_inline_size_limit', function() {
return 50000; // Size in bytes.
}); |
THIS PR IS AN EXPERIMENT. NOT TO MERGE.
What?
This PR disables per-block stylesheet, making all core block styles be enqueued as part of the block-library stylesheet instead.
Why?
I'd like to see whether it impacts front-end metrics (TTFB and LCP) in our CI environment.
How?
The implementation is a hack, it's not to be shipped.
This disables the
should_load_separate_core_block_assets
filter.Testing Instructions
Using TT3, go to the front-end and verify that the block-library stylesheet is present and that there is no per-block stylesheets.