Skip to content

Try: get_style_nodes: only return those that will be used#53575

Closed
oandregal wants to merge 2 commits intotrunkfrom
remove/block-nodes-from-filter
Closed

Try: get_style_nodes: only return those that will be used#53575
oandregal wants to merge 2 commits intotrunkfrom
remove/block-nodes-from-filter

Conversation

@oandregal
Copy link
Copy Markdown
Member

Part of #45171
Extracted from #53351

What?

Do not compute block nodes in get_style_nodes as they will be discarded.

Why?

The block nodes are discarded and are calculated via a different mechanism. By not doing unnecessary work, the code is faster.

How to test

TBD.

WordPress core uses that filter to remove the block nodes. A more performant
implementation is simply return the top-level style nodes.

This needs removing the filter wp_theme_json_get_style_nodes in core as well.
@oandregal oandregal self-assigned this Aug 11, 2023
@oandregal oandregal added the [Type] Performance Related to performance efforts label Aug 11, 2023
@github-actions
Copy link
Copy Markdown

This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress.

If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged.

If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack.

Thank you! ❤️

View changed files
❔ lib/class-wp-theme-json-gutenberg.php
❔ lib/script-loader.php

@oandregal oandregal changed the title Remove/block nodes from filter Try: get_style_nodes: only return those that will be used Aug 11, 2023
@oandregal
Copy link
Copy Markdown
Member Author

In block themes that enqueue the assets of the blocks in use, this change provides a small improvement (-2ms), it could be a little nice win. I'm confused as to why TTFB is worse for classic themes with this change (-4ms). Needs more investigation.

Captura de ecrã 2023-08-18, às 17 31 36

@oandregal oandregal closed this Apr 19, 2024
@oandregal oandregal deleted the remove/block-nodes-from-filter branch April 19, 2024 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Performance Related to performance efforts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant