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

Avoid getTheme call when slug is null #95570

Merged
merged 1 commit into from
Oct 22, 2024
Merged

Avoid getTheme call when slug is null #95570

merged 1 commit into from
Oct 22, 2024

Conversation

lsl
Copy link
Contributor

@lsl lsl commented Oct 22, 2024

Related to # p55Cj4-3EI-p2

Proposed Changes

Prevents unnecessary call to wp/v2/sites/:site/themes

Why are these changes being made?

When there is no theme being previewed and theme slug was undefined the getTheme call was makes a fallback call to get all themes instead of just the one theme. This call takes 10s on dotcom and was blocking the site editor from rendering.

Testing Instructions

Confirm only one theme call is made on site editor load:

Also confirm live preview still renders correctly:

Screenshot(81)

Before

Screenshot_2024-10-22_11-44-25

After

Screenshot_2024-10-22_11-42-27

@matticbot
Copy link
Contributor

This PR does not affect the size of JS and CSS bundles shipped to the user's browser.

Generated by performance advisor bot at iscalypsofastyet.com.

@lsl lsl requested a review from a team October 22, 2024 01:13
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Oct 22, 2024
@lsl lsl self-assigned this Oct 22, 2024
previewingThemeSlug,
previewingThemeName: undefined,
};
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using both approaches to be a little more defensive with this hook, only one is technically needed.

Copy link
Contributor

@taipeicoder taipeicoder left a comment

Choose a reason for hiding this comment

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

LGTM! Could you add the Lego Maintenance label?

Copy link
Contributor

@arthur791004 arthur791004 left a comment

Choose a reason for hiding this comment

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

Tested and works as expected 👍

@lsl lsl merged commit dee6c50 into trunk Oct 22, 2024
18 checks passed
@lsl lsl deleted the update/themes-preview branch October 22, 2024 04:13
@github-actions github-actions bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants