Make WordPress Core

Opened 17 months ago

Last modified 4 months ago

#58801 assigned enhancement

Prefetch Block Editor from Posts page

Reported by: adamsilverstein's profile adamsilverstein Owned by: adamsilverstein's profile adamsilverstein
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Editor Keywords: dev-feedback needs-unit-tests needs-testing has-patch
Focuses: performance Cc:

Description

One of the most common user journeys in wp-admin for creating or editing a Post is navigating to the Posts page (wp-admin/edit.php) then to the Block Editor (either by clicking a post to edit or clicking the "New Post" button or sidebar menu).

We can greatly increase up the speed with which the editor loads by prefetching the edit screen once the user reaches the Posts page. Prefetch will "prime the html cache" for all of the resources needed by the editor, resulting in the editor loading much faster for users.

Note: since users can also reach the editor from the wp-admin bar, we might want to consider adding prefetch when the user interacts or opens the "New" menu. However, to keep this initial proposal small and easier to test I decided to limit the scope to the Posts page.

Attachments (1)

58801.diff (420 bytes) - added by adamsilverstein 17 months ago.

Download all attachments as: .zip

Change History (9)

This ticket was mentioned in PR #4843 on WordPress/wordpress-develop by @adamsilverstein.


17 months ago
#1

  • Keywords has-patch added; needs-patch removed

#3 @adamsilverstein
17 months ago

  • Owner set to adamsilverstein
  • Status changed from new to assigned

This could use some benchmarking and maybe a unit test. It could also be nice to add a "editor load time" metric to our automated performance testing.

Testing instructions:
Complete the following steps before and after patch:

  • Clear browser cache or start a fresh incognito session
  • Log in and navigate to the Posts page
  • Check network console to see the prefetch take place (wp-admin/post-new.php)
  • Try editing a post or creating a new post
  • Record the time it takes for the editor to load and be ready to accept your input

More dramatic results with network throttling enabled.

Expected result: the editor should load noticeably faster with the patch.

Version 1, edited 17 months ago by adamsilverstein (previous) (next) (diff)

#4 @johnbillion
17 months ago

  • Version trunk deleted

#5 @mukesh27
17 months ago

  • Milestone changed from Awaiting Review to Future Release

This ticket was discussed in the recent Performance bug scrub.

moving to Future Release for consideration.

Additional props to @joemcgill

#6 follow-up: @westonruter
13 months ago

Whenever a user visits the wp-admin/post-new.php, an auto-draft post gets created in the DB.

For example, when I view source of that page I see:

<input type='hidden' id='post_ID' name='post_ID' value='151' />

And when I reload I see:

<input type='hidden' id='post_ID' name='post_ID' value='152' />

Will the fact that this is getting prefetched be a problem?

#7 in reply to: ↑ 6 @adamsilverstein
4 months ago

Replying to westonruter:

Whenever a user visits the wp-admin/post-new.php, an auto-draft post gets created in the DB.

Ah, good catch!

We should be able to address that on the post-new.php side by not firing the initial autosave when we detect a prerender.

#8 @westonruter
4 months ago

I guess then that post-new.php wouldn't be able to call get_default_post_to_edit() (which creates the auto-draft post) and that this should instead be done via JS and the REST API when the page has loaded (and not in a prerendered state)?

Note: See TracTickets for help on using tickets.