-
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 opening of the block inserter via manual token-based analysis of reusable blocks #35763
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mcsf
added
[Feature] Inserter
The main way to insert blocks using the + button in the editing interface
[Type] Performance
Related to performance efforts
[Feature] Synced Patterns
Related to synced patterns (formerly reusable blocks)
labels
Oct 19, 2021
mcsf
commented
Oct 19, 2021
Size Change: +9.55 kB (+1%) Total Size: 1.08 MB
ℹ️ View Unchanged
|
cc @sathyapulse |
7 tasks
mcsf
force-pushed
the
fix/reusable-block-inserter-perf-alt1
branch
from
October 20, 2021 09:44
8c89ba1
to
b4c99c7
Compare
mcsf
force-pushed
the
fix/reusable-block-inserter-perf-alt1
branch
from
October 22, 2021 11:02
b4c99c7
to
ab9a6ad
Compare
adamziel
approved these changes
Oct 28, 2021
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.
🚢
The failing PHP unit tests pertain to unrelated changes to Global Styles. Merging! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
[Feature] Inserter
The main way to insert blocks using the + button in the editing interface
[Feature] Synced Patterns
Related to synced patterns (formerly reusable blocks)
[Type] Performance
Related to performance efforts
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Alternative to #35724.
Fixes #35719.
Props @sathyapulse for identifying the bottleneck.
Description
In the
getInserterItems
block-editor selector,buildReusableBlockInserterItem
parses every saved reusable block in order to identify its outermost block type, so that the inserter UI can display the icon of said block type.This function previously relied on parsing every saved reusable block using the full block parser, i.e.
wp.blocks.parse
. This is orders of magnitude slower than raw parsing, which excels at only retrieving the block topology, and is made available bywp.blockSerializationDefaultParser.parse
.This pull request extracts the tokenizer regular expression used in package
block-serialization-default-parser
and uses it to match the very first block boundary found in a reusable block's markup. This should be significantly faster when a site has thousands of saved reusable blocks.How has this been tested?
Types of changes
Performance fix.
Checklist:
*.native.js
files for terms that need renaming or removal).