-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Closed
Labels
[Type] PerformanceRelated to performance effortsRelated to performance efforts
Description
When loading the Navigation screen, there are a lot of loading spinners due to API requests to /menus
and /menu-items
. We should preload these requests so that the screen appears faster.
For reference, here's how edit-site
does this:
gutenberg/lib/edit-site-page.php
Lines 153 to 172 in f62d5ea
// Preload block editor paths. | |
// most of these are copied from edit-forms-blocks.php. | |
$preload_paths = array( | |
'/?context=edit', | |
'/wp/v2/types?context=edit', | |
'/wp/v2/taxonomies?context=edit', | |
'/wp/v2/pages?context=edit', | |
'/wp/v2/themes?status=active', | |
array( '/wp/v2/media', 'OPTIONS' ), | |
); | |
$preload_data = array_reduce( | |
$preload_paths, | |
'rest_preload_api_request', | |
array() | |
); | |
wp_add_inline_script( | |
'wp-api-fetch', | |
sprintf( 'wp.apiFetch.use( wp.apiFetch.createPreloadingMiddleware( %s ) );', wp_json_encode( $preload_data ) ), | |
'after' | |
); |
Metadata
Metadata
Assignees
Labels
[Type] PerformanceRelated to performance effortsRelated to performance efforts