-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Performance: Improve StyleBook resize responsiveness for Classic Theme #68980
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. |
I think last usage of |
Size Change: -10 B (0%) Total Size: 1.84 MB
ℹ️ View Unchanged
|
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.
Thanks, @t-hamano!
This looks good to me ✅
@Mamaduka Thanks for the review! |
What?
This PR improves resize responsiveness by removing unnecessary resize observers from the StyleBook for the Classic theme.
Closes #68978
Why?
When I measured with the browser developer tools, I confirmed that a large number of requests like the one below were generated every time the canvas was resized:
These seem to be related to dynamic blocks that are rendered on the server side.
I suspected that this was due to the
StyleBook
component andStyleBookPreview
component using theuseResizeObserver
hook, which causes re-rendering every time the canvas is resized.How?
This hook seems to be used to monitor the width of the container and add the CSS selector
is-wide
when the width is 600px or more. However, this CSS selector is not used anywhere (See this stylesheet).When I remove these resize observers, the resizing responsiveness of the canvas seems to improve dramatically.
Testing Instructions
Screenshots or screencast
Compare this to the video uploaded in #68978.
4efc8f5d107f7f1e4621238fcda537d3.mp4