Skip to content
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

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

Closed
wants to merge 2 commits into from

Conversation

oandregal
Copy link
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

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
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