Performance: Improve opening of the block inserter via manual token-based analysis of reusable blocks#35763
Merged
Merged
Conversation
mcsf
commented
Oct 19, 2021
|
Size Change: +9.55 kB (+1%) Total Size: 1.08 MB
ℹ️ View Unchanged
|
Contributor
Author
|
cc @sathyapulse |
7 tasks
8c89ba1 to
b4c99c7
Compare
b4c99c7 to
ab9a6ad
Compare
Contributor
Author
|
The failing PHP unit tests pertain to unrelated changes to Global Styles. Merging! |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
getInserterItemsblock-editor selector,buildReusableBlockInserterItemparses 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-parserand 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.jsfiles for terms that need renaming or removal).