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

Feat: adds LazyLoadingSection component - perf #2521

Merged
merged 6 commits into from
Oct 28, 2024

Conversation

hellofanny
Copy link
Contributor

@hellofanny hellofanny commented Oct 23, 2024

What's the purpose of this pull request?

Adds LazyLoadingSection component, it will be responsible for lazy loading Sections that are out of the viewport.

  • It achieves this by:
    1. Using the IntersectionObserver API for Sections below the fold.
    1. Checking the UI context for Sections that are not in the viewport, such as the CartSidebar and RegionModal.

We will be implementing this in the RenderSectionsBase as part of our upcoming tasks. This component is not being applied in isolation due to concerns about increased Cumulative Layout Shift (CLS).

How to test it?

  1. You can use this preview link, where the LazyLoadingSection is temporary applied or locally add it in RenderSectionsBase component.
 <SectionBoundary key={`cms-section-${name}-${index}`} name={name}>
      <LazyLoadingSection sectionName={name}>
           <Component {...data} />
      </LazyLoadingSection>
 </SectionBoundary>

  1. Inspect the code, use the React extension for this test:
    • search for Footer, you won't find it until you scroll the page until the Newsletter section
image image
test-lazyloadingsection.mov

Starters Deploy Preview

vtex-sites/starter.store#586

References

#2404

Copy link

vercel bot commented Oct 23, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
faststore-site ⬜️ Ignored (Inspect) Visit Preview Oct 24, 2024 7:33pm

Copy link

codesandbox-ci bot commented Oct 23, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@hellofanny hellofanny changed the title Feat/lazy loading section sfs 1508 Feat: adds LazyLoadingSection component - perf Oct 24, 2024
@hellofanny hellofanny marked this pull request as ready for review October 24, 2024 13:47
@hellofanny hellofanny requested a review from a team as a code owner October 24, 2024 13:47
@hellofanny hellofanny requested review from emersonlaurentino and renatamottam and removed request for a team October 24, 2024 13:47
@hellofanny hellofanny self-assigned this Oct 24, 2024
@pedromtec
Copy link
Contributor

Do you test the web vitals score?

@hellofanny
Copy link
Contributor Author

Do you test the web vitals score?

Yes, locally. But since I'm not using this component yet, it shouldn't make any changes. I found that we introduced CLS with the recent changes, but I will address that in another PR.

image

@hellofanny hellofanny merged commit 04d045d into main Oct 28, 2024
8 checks passed
@hellofanny hellofanny deleted the feat/lazy-loading-section-sfs-1508 branch October 28, 2024 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants