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.
The HTML document generated for the
/wp-admin/post.phppage, i.e., the block editor, contains a very large (200-500kB depending on site setup and plugins) inline script with block pattern definitions: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
.contentattributes 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
__experimentalBlockPatternCategorieshas a similar issue and a REST endpoint would suit it much better, but from a performance standpoint, it's not a pressing issue.