-
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
Lazy initialization of block variants. #45601
Comments
Blocks, or any derivative thereof (such as templates), shouldn't be part of the Post Type API, for they aren't Post Types. In that, I think I'm confident the Post Type API eased the integration for storing and filtering, but it should be a short-term strategy. Keeping the system as-is will cause it to be maintained into an indomitable blob of code debt. |
@spacedmonkey, what's your plan for making the block variations lazily loadable? Changing type for A good start would be |
Sorry for the slow reply. They're only needed where template parts can be edited, currently I believe that's only in the site editor. |
If you are right @talldan could we just register the variants when a user is logged in. gutenberg/packages/block-library/src/template-part/index.php Lines 261 to 273 in 0ff9e08
This seems like a simple change. |
My preference would be the general solution via the Blocks API, instead of handling this per-block basis. It would be easier to document, and we can always recommend lazy initialization for variables that are generated from DB. cc @gziolo |
Using the blocks api sounds related to #22812 |
While it's definitely a related issue, I don't think it should be a requirement for the enhancement. |
I don't know how site editor ues these variants, so it is hard to make a recommendation. If you need to load this data via the REST API, I can help with that, but someone with javascript knowledge will need to help with making this change. The long this is left, the more of a B/C break this will be, so I want to get this fixed ASAP. |
There shouldn't be any JS involved in this enhancement. The blocks are bootstrapped via The main problem we might face here is that we'll need to land changes in the core before the Gutenberg plugin can use it. |
@Mamaduka This change is going to be hard to do in gutenberg. Should I work on it in core then? |
Correct, we can't change those files in the plugin. The core PR sounds good to me. We can conditionally provide |
I put together a little POC PR - WordPress/wordpress-develop#4857. It is a same breaking change. We need to investigation more. |
This was resolved via WordPress/wordpress-develop#5718. |
What problem does this address?
Follow issue related to #45362 (review)
The template part block, loads block variants what load WP_Query and result in database queries. This means that when a block is registered ( on every page request ), that an mostly unnecessary database query is run. There needs to be a way to load lazily the block variants, only when needed.
Props @talldan @Mamaduka
What is your proposed solution?
The text was updated successfully, but these errors were encountered: