Try generating block element selectors only when element styles exist - #79465
Try generating block element selectors only when element styles exist#79465tellthemachines wants to merge 2 commits into
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Flaky tests detected in a859f86. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/28077257124
|
What?
The description of #76556 states that "For one site I was using to test with I found that there were over 4,000 calls to prepend_to_selector() just to bootstrap WordPress". That sounds like a lot for a function that's only called inside
get_block_element_selectorsso I looked into it. Turns out we're generating element selectors for every single block that's registered (not even only the blocks on the page that loads), whether it has element styles or not. We shouldn't need to do that.This PR introduces a check for the existence of element styles, or nested element styles inside breakpoints or style variations for each block, so that we can generate the selectors only for the blocks that need them.
This is not intended as a replacement for #76556, but as a further optimisation.
Testing Instructions
Check that element styles are still being applied correctly to blocks, their viewport state styles and their style variations.
Use of AI Tools
Used codex/gpt 5.5 to validate my initial assessment and make changes based on it. Human reviewed by myself.