-
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
Site editor: preload post if needed #66631
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. |
lib/compat/wordpress-6.8/preload.php
Outdated
@@ -10,6 +10,10 @@ | |||
*/ | |||
function gutenberg_block_editor_preload_paths_6_8( $paths, $context ) { | |||
if ( 'core/edit-site' === $context->name ) { | |||
if ( ! empty( $_GET['postId'] ) ) { | |||
$paths[] = add_query_arg( 'context', 'edit', rest_get_route_for_post( $_GET['postId'] ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this will preload any entity (template, post, etc..)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By quickly testing it, probably not for templates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a great question! Actually postId for templates can be a string instead of a number, so for templates rest_get_route_for_post
will indeed return an empty string. I added a guard against that in 0601aec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Co-authored-by: ellatrix <ellatrix@git.wordpress.org> Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
What?
Whenever one directly accesses a page in the site editor, preload the page. This is a blocking request: the editor will not load without it.
In the post editor, we already do this: https://github.com/WordPress/wordpress-develop/blob/1508e5bf0fa3ad2d001de08eab4dee49985bb322/src/wp-admin/edit-form-blocks.php#L52
Why?
Users might directly access the page editor in the Site Editor.
Also, this is one of the metrics we track directly. We actually do not track Site Editor load performance for the front-page (the initial Site Editor page).
How?
Preload it.
Testing Instructions
/wp-admin/site-editor.php?postType=page&postId=<ID>&canvas=edit
. Open the network tab. Reload the editor. Observe that the REST request for the page is gone.Testing Instructions for Keyboard
Screenshots or screencast