Skip to content

Conversation

@dcalhoun
Copy link
Member

@dcalhoun dcalhoun commented May 12, 2025

What?

Rely upon a cache to avoid unnecessary network requests during editor initialization.

Why?

We invoke loadEditorAssets twice—once for i18n modules, and then again for all other @wordpress modules. The second invocation is performed immediately after the first, and there is no benefit for requesting a new response.

How?

Cache the API endpoint response in memory. Long-term, we plan to cache the response and the assets themselves, which is explored in #107.

Testing Instructions

  1. Test while using a build of the WordPress app with the Gutenberg/experimental editor _plugins debug flag enabled.
  2. Monitor your testing device's network activity.
  3. Open the remote or site-specific editor.
  4. Verify a single request to the editor assets endpoint is performed.

Accessibility Testing Instructions

N/A, no user-facing changes.

Screenshots or screencast

N/A, no user-facing changes.

@dcalhoun dcalhoun added the [Type] Performance Related to performance efforts label May 12, 2025
* @typedef {Object} EditorAssetConfig
*
* @property {string[]} allowedBlockTypes Array of allowed block types provided by the API.
* @property {Object} wpDependencies WordPress dependencies, empty when allowedPackages is provided.
Copy link
Member Author

Choose a reason for hiding this comment

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

This was removed in a separate commit as its usage was removed entirely in an earlier commit.

@dcalhoun dcalhoun marked this pull request as ready for review May 12, 2025 20:25
@dcalhoun dcalhoun requested a review from kean May 12, 2025 20:26
Base automatically changed from feat/internationalization to trunk May 12, 2025 20:45
dcalhoun added 2 commits May 12, 2025 16:55
The usage was removed in earlier commits.
We now utilize the `loadEditorAssets` utility twice--once to load i18n
modules, again to load the remaining `@wordpress` modules. The second
invocation occurs immediately after the first, and there is no benefit
from making another network request.
@dcalhoun dcalhoun force-pushed the perf/cache-editor-assets-response branch from 30c0cec to 45a84bf Compare May 12, 2025 20:55
@dcalhoun
Copy link
Member Author

Rebased to exclude the now merged feat/internationalization branch.

@dcalhoun dcalhoun merged commit db0ed16 into trunk May 13, 2025
10 checks passed
@dcalhoun dcalhoun deleted the perf/cache-editor-assets-response branch May 13, 2025 17:46
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