Skip to content

Site Editor: preload template parts, query posts, and taxonomies used during initial canvas load #78074

@chubes4

Description

@chubes4

What problem does this address?

The Site Editor still issues several REST requests during the initial editor canvas load that appear to be known up front and can be preloaded server-side. In a Studio/Playground-style local environment where each WordPress REST request is relatively expensive, these missed preloads add a stable ~500ms to the measured Site Editor load path.

This is not specific to Studio UI code. Studio amplifies the cost, but the missed requests are WordPress/Gutenberg Site Editor requests after site-editor.php has already rendered the preload payload.

Observed missed requests

On the measured Site Editor path, these requests were made after page boot and before the canvas reached the ready gate:

/wp-json/wp/v2/template-parts/twentytwentyfive//header?context=edit&_locale=user
/wp-json/wp/v2/template-parts/twentytwentyfive//footer?context=edit&_locale=user
/wp-json/wp/v2/posts?context=edit&offset=0&order=desc&orderby=date&per_page=10&ignore_sticky=false&_locale=user
/wp-json/wp/v2/posts?context=edit&offset=0&order=desc&orderby=date&per_page=3&ignore_sticky=false&_locale=user
/wp-json/wp/v2/taxonomies?context=view&_locale=user

The current preload list already includes template/template-part collection routes, settings, navigation, etc., but the collection preload does not satisfy the individual getEntityRecord lookups for template parts.

Evidence

A local A/B harness compared current Site Editor loading against a dynamic preload candidate that:

  • preloads every get_block_templates( array(), 'wp_template_part' ) template-part ID individually
  • preloads the observed query-loop post collection routes for per_page=10 and per_page=3
  • preloads /wp/v2/taxonomies?context=view

Two-run local probe summary:

baseline avg: 1445ms
dynamic preload candidate avg: 941ms
delta: -504ms / -34.9%
baseline measured REST resources: 5
candidate measured REST resources: 0

Durable Homeboy-rigs workload smoke result after extracting this into a reusable benchmark:

baseline_site_editor_measure_ms: 1443
candidate_site_editor_measure_ms: 943
site_editor_preload_delta_ms: -500
site_editor_preload_delta_pct: -34.6
baseline_measure_resource_count: 5
candidate_measure_resource_count: 0

Harness PR: chubes4/homeboy-rigs#106

Related prior work

This looks like a follow-up to earlier Site Editor preload work, not a duplicate:

Notes

The preload cache should use the normalized REST path without _locale=user; apiFetch's locale middleware appends _locale=user after the preload middleware checks the original path.

The template part routes should be derived dynamically rather than hardcoding twentytwentyfive//header or twentytwentyfive//footer.

Metadata

Metadata

Assignees

Labels

[Feature] Site EditorRelated to the overarching Site Editor (formerly "full site editing")[Status] In ProgressTracking issues with work in progress[Type] PerformanceRelated to performance efforts

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions