-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Block visibility based on screen size: don't subscribe to state in the hook #74481
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
Block visibility based on screen size: don't subscribe to state in the hook #74481
Conversation
…m context, the intention is to reduce unnecessary store subscriptions.
|
Size Change: -5 B (0%) Total Size: 3.08 MB
ℹ️ View Unchanged
|
|
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. |
Mamaduka
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. Thanks, @ramonjd!
andrewserong
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, too quick @Mamaduka 😄
LGTM too!
🎉 |
In my experinces 99% of the time it's extra store subscription causing perf regression 😓 |
Thanks for confirming. I should have remembered that too. Appreciate @talldan picking it up and to you folks for the speedy review |

Follow up to #74379 (review)
Updated
useBlockVisibilityto accept block visibility and device type from context, with the intention to reduce unnecessary store subscriptions.Kudos to @talldan for picking up on it.
Here's the result of my local performance tests (note, they might not be reliable as I was listening to YouTube, working in an IDE with 10 AI agents running, and also mining Bitcoin at the same time)
If this doesn't work, I'll roll back #74379
Why?
Trying to fix a performance regression. See #74379 (review) and graph at https://www.codevitals.run/project/gutenberg/inserterHover
How?
useBlockVisibilityto accept options directly (noclientIdor store access)block.jsanduse-block-props/index.jsto pass data from existinguseSelectcallsblockVisibility = undefined,deviceType = 'desktop'Testing Instructions
Smoke test block visibility (test steps over at #74379)