Skip to content

Avoid registering patterns on the frontend#5397

Closed
aristath wants to merge 3 commits intoWordPress:trunkfrom
aristath:performance/doNotLoadPatternsOnFront
Closed

Avoid registering patterns on the frontend#5397
aristath wants to merge 3 commits intoWordPress:trunkfrom
aristath:performance/doNotLoadPatternsOnFront

Conversation

@aristath
Copy link
Copy Markdown
Member

@aristath aristath commented Oct 4, 2023

Trac ticket: https://core.trac.wordpress.org/ticket/59532


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@aristath aristath marked this pull request as ready for review October 4, 2023 08:29
Comment on lines +331 to +334
// Avoid registering patterns on the frontend.
if ( ! is_admin() && ! wp_is_json_request() ) {
return;
}
Copy link
Copy Markdown
Member

@swissspidy swissspidy Oct 4, 2023

Choose a reason for hiding this comment

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

If we are doing checks like this, we are we even hooking this function on init? We could just call it conditionally where needed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, I was thinking about that as well... My concern is that many things in the editor are done in REST-API calls, and a hook like admin_init wouldn't be suitable in that case. Do you have any ideas on a hook that would work?

This patch here works when manually testing, I'm trying to figure out how to fix the PHPUnit failures now

@aristath aristath marked this pull request as draft October 4, 2023 09:17
@aristath
Copy link
Copy Markdown
Member Author

aristath commented Oct 4, 2023

Closing in favor of #5398
Lazy-loading patterns is a better solution.

@aristath aristath closed this Oct 4, 2023
@aristath aristath deleted the performance/doNotLoadPatternsOnFront branch October 4, 2023 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants