-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
perf(v2): lazy sidebar categories / collapsibles, reduce html output / build times #5136
Conversation
✔️ [V2] 🔨 Explore the source changes: d94cea5 🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/60eeedef61ab790008082531 😎 Browse the preview: https://deploy-preview-5136--docusaurus-2.netlify.app |
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-5136--docusaurus-2.netlify.app/ |
Size Change: -123 kB (-13%) 👏 Total Size: 850 kB
ℹ️ View Unchanged
|
This can have huge impact on sites with very large sidebars, and a good impact on smaller sites too! Note some very large sites already use a trick to avoid rendering the sidebar on SSR and can save up to 12min build time!: demisto/content-docs#616 (comment) function DocSidebarBrowser(props) {
return (
<BrowserOnly
fallback={<div>Sidebar...</div>}>
{() => {
// Something that should be excluded during build process prerendering.
return <DocSidebar {...props} />
}}
</BrowserOnly>
);
} I think current PR is a good compromise to avoid delaying the visibility of the sidebar and keep acceptable perfs. Obviously it will remain faster to simply not render the sidebar on the server. |
@jdevalk may I ask you what you think about the potential SEO impacts of server-rendering only a subset of the full sidebar? |
The risk is that search engines won't follow the links in the parts of the sidebar that aren't rendered immediately. So pages deeper are more clicks away from the main page. Whether that's a problem depends on how many links point to that documentation, but I've seen some docusaurus sites that have such hideously long menu's that that's not ideal either. So in all, especially as it'll make pages faster, I think this is a smart change to make. |
Thanks 😜 let's use this by default then and maybe we'll add a config
option later if it's requested.
Note later we'll make category index pages/doc so crawlers will be able to
more easily navigate down the tree
Le ven. 9 juil. 2021 à 19:44, Joost de Valk ***@***.***> a
écrit :
… The risk is that search engines won't follow the links in the parts of the
sidebar that aren't rendered immediately. So pages deeper are more clicks
away from the main page. Whether that's a problem depends on how many links
point to that documentation, but I've seen some docusaurus sites that have
such hideously long menu's that that's not ideal either. So in all,
especially as it'll make pages faster, I think this is a smart change to
make.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#5136 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFW6PVYYG5N4XZ37RCSGYDTW4YODANCNFSM5ADDA42Q>
.
|
# Conflicts: # packages/docusaurus-theme-common/src/utils/useCollapsible.tsx
👍 this seems to work fine! |
Motivation
Allowing collapsibles (ie sidebar categories) to be "lazy" can reduce significantly the HTML markup.
Fix #4753
Many sites have very large sidebars and the sidebar markup is responsible for a huge part of the HTML content + build time.
We should avoid rendering collapsed items on the server, and delay rendering until the first expansion.
Note: this can have an SEO impact, as crawlers won't see the whole sidebar anymore, but I believe it's fine because crawlers can still navigate the site through direct sidebar siblings and the next/previous buttons. I also believe crawlers would understand better that certain pages are related together and form "semantic cocoons" because only sidebar siblings/ancestors are rendered now.
Have you read the Contributing Guidelines on pull requests?
yes
Test Plan
preview
Related PRs
(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/docusaurus, and link to your PR here.)