#58560 closed enhancement (fixed)
Performance issues with `wp_common_block_scripts_and_styles`
Reported by: | spacedmonkey | Owned by: | spacedmonkey |
---|---|---|---|
Milestone: | 6.3 | Priority: | normal |
Severity: | normal | Version: | 5.0 |
Component: | Script Loader | Keywords: | has-patch has-unit-tests commit |
Focuses: | performance | Cc: |
Description
In function wp_common_block_scripts_and_styles
is bad for performance. This is because it does a lot of file operations. Uses glob
and file_get_contents
. This does this for styles are may not even be loaded on a page.
Change History (13)
This ticket was mentioned in PR #4707 on WordPress/wordpress-develop by @spacedmonkey.
15 months ago
#2
- Keywords has-patch has-unit-tests added
Trac ticket: https://core.trac.wordpress.org/ticket/58560
#4
@
15 months ago
- Milestone changed from Future Release to 6.3
- Version set to 5.0
Benchmarks, 1000 runs on TT2.
Trunk | PR | |
Response Time (median) | 126.62 | 114.16 |
wp-load-alloptions-query (median) | 1.42 | 1.41 |
wp-before-template (median) | 47.75 | 48.31 |
wp-before-template-db-queries (median) | 6.45 | 6.43 |
wp-template (median) | 73.97 | 61.42 |
wp-total (median) | 121.88 | 109.85 |
wp-template-db-queries (median) | 3.95 | 3.91 |
The theme has to have add_theme_support( 'wp-block-styles' );
to see the benefit, so using TT2 for the benchmarks is important.
#5
@
15 months ago
Thanks @spacedmonkey for looking into this. I also ran a set of benchmarks and can confirm a notable performance impact, which makes this worth considering even this late in the cycle. The numbers I see are even more impactful, resulting in a crazy 35% performance improvement (wp-total
metric) when using TT2. I can also confirm that this performance improvement only applies to block themes that have theme support for "wp-block-styles".
See this spreadsheet for the full benchmarking results.
With that said, I am personally not familiar and comfortable enough with the underlying logic to approve the PR by myself. It would be great to have someone else more familiar with the underlying logic review. Maybe @noisysocks @oandregal?
This ticket was mentioned in Slack in #core by chaion07. View the logs.
15 months ago
@oandregal commented on PR #4707:
15 months ago
#7
I've done some search, but it's difficult to pinpoint who was involved in this work, given all the moving code around between core and gutenberg. Playing by ear and pinging @aristath, as he has worked in this area, in case he can provide feedback.
#8
@
15 months ago
Testing instructions.
- Activate TT2 theme.
- Create a post.
- Insert the following blocks
audio
,code
,gallery
,image
,quote
,search
. - Add title and publish.
- Navigate to post on FE.
- View source of page.
- Search for
wp-block-<block_name>-theme-inline-css
. - Ensure that all of the block listed above have inline theme styles.
@oandregal Testing details
@spacedmonkey commented on PR #4707:
15 months ago
#9
Thanks for the PR @spacedmonkey! I left one nitpick that can be addressed here or in a follow-up "catch-all" commit, so it's not a blocker.
@costdev Feedback complete.
There is a PR with a fix here. https://github.com/spacedmonkey/wordpress-develop/pull/4
This ticket is blocked by #58528