Site Editor: preload initial canvas data#78075
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Updated this to make the preload set route/template-aware rather than broad/unconditional. The implementation now derives likely template slugs from the standard template hierarchy, resolves pattern blocks, and only preloads template parts/query data when present in the resolved initial template. I also added static-front-page coverage for the page record, template lookup, and page type requests, since those are deterministic for Supporting benchmark scenarios are in chubes4/homeboy-rigs#108. |
|
Pushed the same follow-up preload additions to the Gutenberg backport. Backport commit: dd5ed07223 The detailed scenario matrix and route-by-route evidence are in the Core PR comment: WordPress/wordpress-develop#11766 (comment) Local validation for the changed backport file,
|
|
Follow-up from the remaining visible REST rows in DevTools: I dug into the preloading middleware keys and caller stacks to separate missing server declarations from client-side duplicate consumers. The current preload patch should stay focused on deterministic initial canvas data. The remaining
One important diagnostics detail: the visible DevTools URL can include So I think the right split is:
The caller-attribution/probe evidence that led to those two issues is captured in this Homeboy run: |
| * | ||
| * @return array Filtered preload paths. | ||
| */ | ||
| function gutenberg_block_editor_preload_paths_6_9( $paths, $context ) { |
There was a problem hiding this comment.
It's odd that this function name was already wrong. 😄
Anyway, WordPress 7.0 is already in the late stages of release and its too late to add an enhancement like this. All of this new preloading code should be in the lib/compat/wordpress-7.1 folder instead (to indicate it's intended to be shipped in the 7.1 release).
There is a README here that explains a bit more - https://github.com/WordPress/gutenberg/blob/trunk/lib/README.md
There was a problem hiding this comment.
Moved to lib/compat/wordpress-7.1/preload.php, and moved the backport changelog entry to backport-changelog/7.1 as well. Thanks for the pointer!
What?
Preloads initial Site Editor canvas data that can be predicted server-side for the initial route/template:
show_on_front=pageWhy?
The Site Editor currently preloads broad template collections, but the first canvas render can still issue several individual REST requests after boot.
In environments where each WordPress REST request has meaningful transport/bootstrap overhead, those missed preloads add visible latency before the editor canvas is ready.
This keeps the preload set route-aware instead of preloading every template-dependent resource unconditionally.
Fixes #78074.
How?
The preload logic derives likely template slugs from the standard WordPress template hierarchy:
page-{post_name},pagefront-page, static-front-page page templates,home,indexIt then resolves pattern blocks and walks the selected template blocks to preload only template parts actually referenced by
core/template-part. Query Loop post collection preloads are added only when the resolved block tree containscore/query.For static front pages, the page record, page template lookup, and page type requests are also deterministic server-side, so those are preloaded for the root Site Editor route when
show_on_front=page.Testing Instructions
Evidence
Supporting Homeboy-rigs benchmark scenarios: chubes4/homeboy-rigs#108
1223ms988ms-235ms / -19.2%5 -> 01876ms874ms-1002ms / -53.4%4 -> 01219ms904ms-314ms / -25.8%3 -> 01277ms897ms-380ms / -29.8%4 -> 0Additional local checks:
Gutenberg CI passes, including PHP coding standards, PHP unit tests, Playwright, and performance tests.
AI assistance