Open youknowriad opened 2 months ago
Patterns are currently preloaded, although I'm not sure why exactly it's needed.
This is also related to #44750 -- one solution for the pattern block is that the server inspects the post_content
markup and preloads only the patterns that are actually used.
Preloading changes also negatively affect editor performance when a site has many patterns. See #64219.
Noting that I'm not talking about editor performance here, but frontend. Having a way to "guess" the patterns of a given page/template could help but I believe we need to first investigate properly what's causing the impact and propose the adequate solutions.
Noting that I'm not talking about editor performance here, but frontend.
Thanks for the clarification, this looks like the _register_theme_block_patterns
is to blame, the one that loads all the theme patterns. For reference it was optimized last year by @spacedmonkey in https://core.trac.wordpress.org/ticket/59490. But it still loads all the patterns upfront, only faster. What we need is that the patterns are loaded lazily, only when needed.
It seems that currently registering patterns in themes (Adding patterns to the
/patterns
folder) impacts negatively the TTFB performance of the frontend. The more patterns we add, the bigger the impact is.I'm guessing this is mostly due to the fact that the patterns need to be registered first before actually using the pattern block in templates...
Is there any optimization we can do here? Can we lazy-register the patterns or avoid registering them until they're needed (pattern block look for them).
cc @oandregal @joemcgill @jsnajdr