-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
performance: use lazy loading for components #12739
Conversation
✅ Deploy Preview for ethereumorg ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm! Loading as expected, maybe just a slight delay on the first load if you go straight to it, but I'm not worried about that given it's location on the page. Nice job!
Wondering if we should just make a helper function for this to lazy load with {ssr: false}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed offline, I still think there is no good reason to lazily load content components from this list at this early stage of the epic.
By content components I'm referring to CommunityEvents
and CalloutBanner
. The contents of these components are visible on the first render (they are included in the html file). If we lazy load them, the content will not be visible to crawlers, which is one of the main reasons we do static rendering of this page.
Also, these components do not have heavy deps. On the contrary, they seem to be pretty small units of code. So I wouldn't expect much difference in perf by including them.
The CodeModal
& Codeblock
are good examples of two components that are great candidates for lazy loading, since they are not visible on the first render and may have other external deps.
This reverts commit c8983f7.
…omepage-lazy-loading
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Will let @pettinarip or @corwintines take another peak, but I think we can get this in for this weeks deploy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nhsz from the code side, it looks good, but don't really know how this is impacting the overall performance. Have you done any analysis? or do you have a bundle size comparison?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nhsz I've ran some tests on this with the bundle analyzer and compare them with dev
.
I've added the results here:
https://docs.google.com/spreadsheets/d/1AKS_h0_xGxyI6L4X9TexJ42IFLkxw6Kc3vgkw5Celfc/edit?usp=sharing
The main _app
file is reduced by ~5kb, which is less than 1% improvement for this bundle (the main source of problems). In addition, these changes create 10 more chunks, which is neither good nor bad, but they add more network requests and redundant payload to each chunk, making the total bundle size even larger than the previous one.
I'm not against using lazy load, but I would use it with caution since we might be adding complexity for no good reason.
For example, there are a few components (Tooltip, GlossaryDefinition) in this list that are less than 4kb uncompressed. So creating a new chunk for them might not seem worthwhile.
IMO there is no significant difference in the bundle sizes. The optimization in general doesn't justify adding more complexity to the codebase.
Not sure the next steps here but lmk your thoughts.
Closing this out per @pettinarip's comment and the internal discussion around this change. Please re-open if you disagree with my understanding here @nhsz |
This PR applies lazy-loading for the following components, to reduce initial JS payload and reduce loading time
Codeblock
CodeModal
FeedbackCard
FeedbackWidget
GlossaryDefinition
GlossaryTooltip
Modal
SimulatorModal
Tooltip