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

[docs-infra] Improve performance hideToolbar: true #37969

Merged
merged 2 commits into from
Jul 17, 2023

Conversation

oliviertassinari
Copy link
Member

@oliviertassinari oliviertassinari commented Jul 14, 2023

A quick clean-up on the logic.

This effort is connected to the need to improve the performance of the docs pages. They should render much faster. We are reinforcing the idea that CSS-in-JS or event our components are slow hence you shouldn't use them.

@oliviertassinari oliviertassinari added core Infrastructure work going on behind the scenes scope: docs-infra Specific to the docs-infra product labels Jul 14, 2023
Comment on lines 375 to 379
if (demoOptions.hideToolbar === false) {
throw new Error(
[
'"hiddenToolbar": false is already the default.',
'"hideToolbar": false is already the default.',
`Please remove the property in {{"demo": "${demoOptions.demo}", …}}.`,
Copy link
Member Author

Choose a reason for hiding this comment

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

A typo

Comment on lines -179 to +184
{canonicalAs.startsWith('/joy-ui/') ? (
{productId === 'joy-ui' ? (
Copy link
Member Author

Choose a reason for hiding this comment

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

More resilient logic

Comment on lines -544 to +564
<NoSsr defer fallback={<DemoToolbarFallback />}>
<NoSsr fallback={<DemoToolbarFallback />}>
Copy link
Member Author

Choose a reason for hiding this comment

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

Extra render useless

});
setDemoKey();
};
const resetDemo = React.useMemo(
Copy link
Member Author

Choose a reason for hiding this comment

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

Memoize to avoid rerendering the DemoSandbox on hover.

{/* TODO: BrandingProvider shouldn't be needed, it should already be at the top of the docs page */}
<BrandingProvider {...(demoData.productId === 'joy-ui' ? { mode } : {})}>
{demoOptions.hideToolbar ? null : (
{demoOptions.hideToolbar ? null : (
Copy link
Member Author

Choose a reason for hiding this comment

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

We can opt-out of a lot more things when demoOptions.hideToolbar is false.

@mui-bot
Copy link

mui-bot commented Jul 14, 2023

Netlify deploy preview

https://deploy-preview-37969--material-ui.netlify.app/

Bundle size report

No bundle size changes (Toolpad)
No bundle size changes

Generated by 🚫 dangerJS against c5a8cc3

@oliviertassinari oliviertassinari merged commit 0591739 into mui:master Jul 17, 2023
@oliviertassinari oliviertassinari deleted the fix-memo-regression branch July 17, 2023 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Infrastructure work going on behind the scenes performance scope: docs-infra Specific to the docs-infra product
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants