WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.49k stars 4.19k forks source link

Performance: Split Classic block and Meta Boxes to their own package #32665

Open gziolo opened 3 years ago

gziolo commented 3 years ago

What problem does this address?

We still have some legacy dependencies present in the block editor that were added to bridge the Classic Editor:

They are always present in the post editor even when they are never used on the website having a huge impact on the size of assets that every user has to download to edit content, example:

https://github.com/WordPress/wordpress-develop/blob/611d953e1509e20bf6a7d40f5710c0ce24b88b89/src/wp-includes/script-loader.php#L242-L247

  1. The Classic block requires the editor script dependency and several TinyMCE scripts and stylesheets to make them work. It impacts not only the post editor but also other screens like the new widgets editor screen.
  2. Meta Boxes require at least the postbox script dependency to operate properly, but in many cases, they depend on TinyMCE and all its assets.

What is your proposed solution?

I discussed with @youknowriad that it'd a good idea to split Classic block and Meta Boxes handling to their own package, e.g., edit-post-compat and tweak the condition to load that package iteratively (to deprecate it over time). The first step could be to make the Classic block and Meta Boxes opt-out on the site.

The ideal scenario would be that the Classic block is available from the Block Directory and everyone can consume it from there when necessary.

Related work

There is a related issue #29681 created by @sarayourfriend for the Classic block that tried to load this block asynchronously which is still unresolved. I believe that both issues still make sense as they address a similar problem but different use cases. Related PRs: #21684, #29681.

There is also a WordPress Trac ticket: https://core.trac.wordpress.org/ticket/48654 which considers a solution/endpoint to lazy-load scripts and styles. It has also a work in progress PR in Gutenberg: https://github.com/WordPress/gutenberg/pull/21244.

The Classic block gets removed for the list of blocks in the widgets editor as of https://github.com/WordPress/gutenberg/pull/32800.

gziolo commented 3 years ago

There is a related issue #33422 reported by @johngodley about the undefined support for core/freeform block when oldEditor variable is not set. It's going to be the same case with the changes proposed in this issue when the Classic Box is not present on the page.

tyxla commented 1 year ago

I'd say it will be interesting how this plays out with the experiment to deprecate TinyMCE. It might be easier if we have fewer use cases when we actually load the Classic block.

gziolo commented 1 year ago

I'd say it will be interesting how this plays out with the experiment to deprecate TinyMCE. It might be easier if we have fewer use cases when we actually load the Classic block.

It would be great to replicate the same experiment for Meta Boxes and add a similar JavaScript proxy for the postbox global.