Skip to content

__experimentalBlockPatterns: can we load them with REST API? #39055

@jsnajdr

Description

@jsnajdr

The HTML document generated for the /wp-admin/post.php page, i.e., the block editor, contains a very large (200-500kB depending on site setup and plugins) inline script with block pattern definitions:

<script id='wp-edit-post-js-after'>
wp.editPost.initializeEditor('editor', "post", 1, {
  ...
  __experimentalBlockPatterns: { ...really big json }
} );
</script>

On one my testing site (Core + Jetpack + Woo) the size of the block patterns JSON is 220kB, on another (WP.com Atomic) it's 510kB. Most of the size are .content attributes with the pattern's HTML content.

The question is whether this patterns list needs to be sent statically on every editor load and whether it needs to block the editor initialization. Could it be a REST endpoint instead, called asynchronously only when it's needed? If I understand things correctly, we don't need the block patterns list to parse and display a post, but only when showing the block inserter UI or when editing a specific pattern?

The __experimentalBlockPatternCategories has a similar issue and a REST endpoint would suit it much better, but from a performance standpoint, it's not a pressing issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] PatternsA collection of blocks that can be synced (previously reusable blocks) or unsynced

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions