-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Image Block: Improve performance by only requesting image metadata if selected. #17504
Conversation
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.
Hi @epiqueras, checking the code it seems that the image object is only needed to select an image size updateImage( sizeSlug ) {...
and to select an image link destination getLinkDestinations() {..
. Can't we extract these small UI pieces into separate small components and request the image object user using useSelect
?
This way if the sizes/link UI is not expanded the image is not request at all.
I don't think that's worth the extra complexity. What if we need it in other places as well? Making the request once selected is perfectly fine from a performance standpoint. |
Doesn't what @jorgefilipecosta proposes aligns closely with the principles we shared when building components? I didn't look inside the code, but I think it makes a lot of sense to use data in components which consume it rather than pass it down from the |
Yeah, but this component is already implemented and the fix is 2 lines. Breaking it into components is almost a complete refactor and shouldn't be tied to this fix. |
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.
I verified this fix works well, I guess breaking the big edit in components would be positive but I agree with @epiqueras it is something we can look after and not as part of this fix.
Fixes #17465
Description
This PR stops image blocks from preemptively requesting image metadata and delays it until the block is selected.
This fixes performance issues with posts that contain many images.
How to test?
Verify that the image block still works as expected and that the issue described in #17465 is no longer happening.
Checklist: