Skip to content
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: Pages: Preload template lookup #66654

Merged
merged 2 commits into from
Dec 2, 2024

Conversation

ellatrix
Copy link
Member

@ellatrix ellatrix commented Oct 31, 2024

What?

Preload the page's template when the page in the site editor is loaded directly.

Why?

The lookup request blocks the loading of the whole editor (a loading indicator is shown).

How?

Preload.

Testing Instructions

Go to the Sited Editor > Pages > edit a page. Check the network tab. Reload an observe no lookup request.

Testing Instructions for Keyboard

Screenshots or screencast

@ellatrix ellatrix added the [Type] Performance Related to performance efforts label Oct 31, 2024
@ellatrix ellatrix marked this pull request as ready for review October 31, 2024 19:18
Copy link

github-actions bot commented Oct 31, 2024

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ellatrix <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: jorgefilipecosta <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@@ -10,11 +10,23 @@
*/
function gutenberg_block_editor_preload_paths_6_8( $paths, $context ) {
if ( 'core/edit-site' === $context->name ) {
if ( ! empty( $_GET['postId'] ) ) {
if ( ! empty( $_GET['postId'] ) && ! empty( $_GET['postType'] ) ) {
Copy link
Member

@Mamaduka Mamaduka Nov 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The $context has a post property, only populated in the post editor. I think we should do the same for the core/edit-site, but when it makes sense. Currently, that would be a page post type.

See: https://developer.wordpress.org/reference/classes/wp_block_editor_context/

Copy link
Member Author

@ellatrix ellatrix Nov 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Mamaduka yes, that's a good idea. We can't do it here correctly, but I did it in the backport: WordPress/wordpress-develop#7695

Copy link
Member

@jorgefilipecosta jorgefilipecosta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works well for me and I feel the editor shows the preview faster.

@ellatrix ellatrix force-pushed the add/site-editor-page-template-preload branch from f09ccf8 to c631dde Compare December 2, 2024 13:06
@ellatrix ellatrix enabled auto-merge (squash) December 2, 2024 15:28
@ellatrix ellatrix merged commit 1d06b35 into trunk Dec 2, 2024
62 of 63 checks passed
@ellatrix ellatrix deleted the add/site-editor-page-template-preload branch December 2, 2024 16:55
@github-actions github-actions bot added this to the Gutenberg 19.9 milestone Dec 2, 2024
im3dabasia pushed a commit to im3dabasia/gutenberg that referenced this pull request Dec 4, 2024
Co-authored-by: ellatrix <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: jorgefilipecosta <[email protected]>
michalczaplinski pushed a commit that referenced this pull request Dec 5, 2024
Co-authored-by: ellatrix <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: jorgefilipecosta <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Performance Related to performance efforts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants