Opened 5 weeks ago
Last modified 4 weeks ago
#65206 assigned enhancement
Site Editor: preload initial canvas REST data
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 7.1 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Editor | Keywords: | has-patch |
| Focuses: | performance | Cc: |
Description
This ticket tracks the WordPress Core sync/backport for a Gutenberg Site Editor preload change.
The Gutenberg issue/PR are already filed here:
- https://github.com/WordPress/gutenberg/issues/78074
- https://github.com/WordPress/gutenberg/pull/78075
This Core ticket is needed for the corresponding wordpress-develop PR that syncs the PHP preload change into src/wp-admin/site-editor.php.
The Site Editor currently misses several REST API preload paths used during the initial editor canvas load, causing avoidable follow-up REST requests for individual template part records, Query Loop post collections, and public taxonomies.
Observed late REST routes included:
/wp/v2/template-parts/<template-part-id>?context=edit/wp/v2/posts?context=edit&offset=0&order=desc&orderby=date&per_page=10&ignore_sticky=false/wp/v2/posts?context=edit&offset=0&order=desc&orderby=date&per_page=3&ignore_sticky=false/wp/v2/taxonomies?context=view
Validation against a Site Editor load benchmark showed the candidate reducing measured load time from 1235ms to 914ms (-321ms / -26.0%) and eliminating the observed late REST resources (5 -> 0).
Change History (16)
This ticket was mentioned in PR #11766 on WordPress/wordpress-develop by @extrachill.
5 weeks ago
#1
@westonruter commented on PR #11766:
5 weeks ago
#2
@westonruter commented on PR #11766:
5 weeks ago
#3
#4
@
5 weeks ago
- Milestone changed from Awaiting Review to Future Release
- Owner set to extrachill
- Status changed from new to assigned
@extrachill commented on PR #11766:
5 weeks ago
#5
I think there is a strong chance the answer is yes. I will run some more tests and see what I can do. Appreciate your feedback.
@extrachill commented on PR #11766:
5 weeks ago
#6
Thanks for asking whether there was room to preload more. I did a focused sweep of the remaining visible REST requests using the Homeboy Site Editor benchmark rig and REST waterfall diff tooling.
What changed in the latest push:
- Added
GET /wp/v2/types/post?context=editwhen the resolved initial template contains a Query Loop. - Added the edit-context page tree request:
GET /wp/v2/pages?context=edit&per_page=100&_fields=id,link,menu_order,parent,title,type&orderby=menu_order&order=asc.
Evidence from the default TT5 Site Editor scenario:
- Original baseline:
34REST requests,19unique,5measured canvas-phase REST resources, ready around1209ms. - Existing route/template-aware candidate: about
22-23REST requests,13unique,0measured canvas-phase REST resources, ready around925ms. - Updated candidate with the two added routes:
20REST requests,12unique,0measured canvas-phase REST resources, ready around894msover a 3-iteration run.
I also tested additional visible REST routes individually. I did not add them because they either did not satisfy the client preload cache key in this scenario or made the critical path worse:
GET /wp-block-editor/v1/navigation-fallback?_embed=trueremoved its target request, but reintroduced measured resources and slowed readiness.GET /wp/v2/users/me?context=edit,GET /wp/v2/pages?context=view...,GET /wp/v2/menus?..., andGET /wp/v2/wp_pattern_category?...did not remove their target requests when preloaded in this scenario.
Tooling used:
- Homeboy Site Editor preload comparison rig: https://github.com/chubes4/homeboy-rigs/pull/113
- REST waterfall comparison/reporting helpers: https://github.com/Extra-Chill/homeboy-extensions/pull/575
Validation run locally:
php -l src/wp-admin/site-editor.php./vendor/bin/phpcs -s --standard=phpcs.xml.dist src/wp-admin/site-editor.php./vendor/bin/phpcs -s --standard=phpcompat.xml.dist src/wp-admin/site-editor.phphomeboy lint --path /Users/chubes/Developer/wordpress-develop@fix-site-editor-preload-canvas-data --extension nodejshomeboy test ...got through build and QUnit (456tests,0failures), then stopped at local PHPUnit setup becausewp-tests-config.phpis not configured.
One caveat: this specific two-route follow-up was validated against the default TT5 Site Editor scenario. I previously attempted the additional static/front-page scenario runs, but those were blocked locally by Studio WP-CLI setup timeouts, so I do not want to overclaim full scenario-matrix coverage for these two extra routes.
@westonruter commented on PR #11766:
5 weeks ago
#7
@extrachill commented on PR #11766:
5 weeks ago
#8
LFG! 🚀
@westonruter commented on PR #11766:
5 weeks ago
#9
Out of curiosity, I tired preloading _all_ REST API requests for my homepage template in the Site Editor:
$preload_paths[] = '/wp/v2/templates/twentytwentyfive//home?context=edit';
$preload_paths[] = '/wp/v2/wp_pattern_category?context=view&per_page=100&_fields=id%2Cname%2Cdescription%2Cslug';
$preload_paths[] = '/wp/v2/block-patterns/patterns';
$preload_paths[] = '/wp/v2/taxonomies?context=edit&per_page=100';
$preload_paths[] = '/wp/v2/menus?context=view&per_page=100';
$preload_paths[] = '/wp/v2/pages?context=view&parent=0&order=asc&orderby=id&per_page=100';
$preload_paths[] = '/wp/v2/navigation/274?context=edit';
$preload_paths[] = '/wp/v2/pages/82?context=edit';
$preload_paths[] = '/wp/v2/pages/84?context=edit';
$preload_paths[] = '/wp/v2/pages/2?context=edit';
$preload_paths[] = array( '/wp/v2/settings', 'OPTIONS' );
$preload_paths[] = array( '/wp/v2/templates/twentytwentyfive//home', 'OPTIONS' );
$preload_paths[] = array( '/wp/v2/templates', 'OPTIONS' );
$preload_paths[] = array( '/wp/v2/navigation', 'OPTIONS' );
$preload_paths[] = array( '/wp/v2/navigation/274', 'OPTIONS' );
I couldn't get these to get preloaded:
@extrachill commented on PR #11766:
5 weeks ago
#10
Was there a measurable impact on speed? The test runs I did found that some of the requests actually slowed down the overall load time when preloaded. There's a chance the harness was flawed in some way.
Do you think the 5 requests that you couldn't get preloaded might point to something deeper worth investigating?
This benchmark tooling is so fun to use, I'm happy to keep poking at things to see how fast we can make it without regressions.
@westonruter commented on PR #11766:
5 weeks ago
#11
Well, I couldn't get all of them to be preloaded so I didn't go that far to measure. I was going to try measuring after all of the requests were preloaded. But if requests aren't in the critical rendering path, then indeed it doesn't make sense to preload since then it just slows down the page from being served.
@extrachill commented on PR #11766:
5 weeks ago
#12
Follow-up from the remaining visible REST rows in DevTools: I traced the preloading middleware keys and caller stacks in Gutenberg, and the duplicate OPTIONS rows are separate client-side follow-ups rather than missing server preload declarations in this backport.
Tracked Gutenberg issues:
- https://github.com/WordPress/gutenberg/issues/78259:
OPTIONS /wp/v2/settingsis fetched once for rootsiteentity schema loading and later again bycanUser( ..., { kind: 'root', name: 'site' } )instead of reusing the first response'sAllowheader. - https://github.com/WordPress/gutenberg/issues/78260:
OPTIONS /wp/v2/navigationcan be requested twice for the same id-less navigation collection permission because resolver args are not normalized/deduped before the first preload entry is consumed.
One diagnostics detail worth preserving: DevTools shows the post-middleware URL with _locale=user, while createPreloadingMiddleware() checks the pre-locale key first. For example, /wp/v2/taxonomies?context=view is the correct preload declaration even when the visible network row is /wp/v2/taxonomies?_locale=user&context=view.
That means this PR/backport should stay focused on predictable server-side Site Editor preload declarations. The remaining duplicate OPTIONS behavior belongs in the linked core-data issues rather than broadening this patch just to chase a zero-request waterfall.
@extrachill commented on PR #11766:
4 weeks ago
#13
@westonruter Your experiments helped expose two upstream bugs:
#14
@
4 weeks ago
Removing trunk version as this is not going to be shipped with WP 7.0 but in the next releases.
## Summary
## Trac ticket
https://core.trac.wordpress.org/ticket/65206
## Gutenberg PR
https://github.com/WordPress/gutenberg/pull/78075
## Testing
php -l src/wp-admin/site-editor.phpgit diff --check## AI assistance