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

performance: use lazy loading for components #12739

Closed
wants to merge 22 commits into from
Closed

Conversation

nhsz
Copy link
Member

@nhsz nhsz commented Apr 15, 2024

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

@nhsz nhsz added the epic 💪 This issue is an epic on our product roadmap label Apr 15, 2024
@nhsz nhsz self-assigned this Apr 15, 2024
@github-actions github-actions bot added content 🖋️ This involves copy additions or edits needs review 👀 labels Apr 15, 2024
Copy link

netlify bot commented Apr 15, 2024

Deploy Preview for ethereumorg ready!

Name Link
🔨 Latest commit 0ad6ad1
🔍 Latest deploy log https://app.netlify.com/sites/ethereumorg/deploys/663a5e509fe2d300088c4ab2
😎 Deploy Preview https://deploy-preview-12739--ethereumorg.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
7 paths audited
Performance: 43 (🟢 up 4 from production)
Accessibility: 92 (🔴 down 1 from production)
Best Practices: 89 (🔴 down 11 from production)
SEO: 97 (🔴 down 3 from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@nhsz nhsz removed content 🖋️ This involves copy additions or edits needs review 👀 labels Apr 15, 2024
@nhsz nhsz marked this pull request as draft April 16, 2024 02:24
@github-actions github-actions bot added content 🖋️ This involves copy additions or edits needs review 👀 labels Apr 22, 2024
@nhsz nhsz marked this pull request as ready for review April 22, 2024 12:52
Copy link
Member

@wackerow wackerow left a 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}

Copy link
Member

@pettinarip pettinarip left a 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.

@github-actions github-actions bot added the tooling 🔧 Changes related to tooling of the project label May 3, 2024
@nhsz nhsz changed the title performance: use lazy loading for homepage components performance: use lazy loading for components May 3, 2024
@nhsz nhsz requested a review from pettinarip May 7, 2024 14:05
Copy link
Member

@wackerow wackerow left a 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

src/components/Simulator/SimulatorModal.tsx Outdated Show resolved Hide resolved
Copy link
Member

@pettinarip pettinarip left a 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?

src/components/Simulator/SimulatorModal.tsx Outdated Show resolved Hide resolved
@corwintines corwintines self-assigned this May 7, 2024
@wackerow wackerow added the question ❓ Further information is requested label May 7, 2024
Copy link
Member

@pettinarip pettinarip left a 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.

@minimalsm
Copy link
Contributor

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

@minimalsm minimalsm closed this May 28, 2024
@github-actions github-actions bot added the abandoned This has been abandoned or will not be implemented label May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
abandoned This has been abandoned or will not be implemented content 🖋️ This involves copy additions or edits epic 💪 This issue is an epic on our product roadmap question ❓ Further information is requested tooling 🔧 Changes related to tooling of the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants