Skip to content

Commit b678305

Browse files
committed
chore: Minor enhancements
1 parent 4e0fb43 commit b678305

File tree

3 files changed

+36
-31
lines changed

3 files changed

+36
-31
lines changed

src/components/Home/FeaturesAtGlanceSection.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ const FeaturesAtGlanceSection = (): JSX.Element => {
212212
>
213213
<Box
214214
component="img"
215+
loading="lazy"
215216
src={placeholderGifs[selectedFeature]}
216217
alt={`Preview ${selectedFeature + 1}`}
217218
sx={{

src/components/Home/ProjectCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const ProjectCard: React.FC<RepositoryInfo & { previewImg: string }> = React.mem
4141
<Card sx={cardStyles}>
4242
{/* Repository preview image */}
4343
<Box sx={imageWrapperStyles}>
44-
<CardMedia sx={imageStyles} image={previewImg} />
44+
<CardMedia sx={imageStyles} image={previewImg} component="img" loading="lazy" />
4545
</Box>
4646

4747
<CardContent sx={cardContentStyles}>

src/pages/Home.tsx

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
import { Box, Container } from '@mui/material';
2-
3-
import CallToActionSection from '@/components/Home/CallToActionSection';
4-
import CommunitySection from '@/components/Home/CommunitySection';
5-
import FeaturesAtGlanceSection from '@/components/Home/FeaturesAtGlanceSection';
6-
import Footer from '@/components/Home/Footer';
1+
import { Box, Container, Skeleton } from '@mui/material';
2+
import React, { lazy, Suspense } from 'react';
73

84
// import SponsorsSection from '@/components/Home/SponsorsSection';
95
// import TestimonialSection from '@/components/Home/TestimonialSection';
10-
import FeaturesAndBenefitsSection from '../components/Home/FeaturesAndBenefitsSection';
116
import HeroSection from '../components/Home/HeroSection';
12-
import ProjectSection from '../components/Home/ProjectSection';
7+
8+
const CallToActionSection = lazy(() => import('@/components/Home/CallToActionSection'));
9+
const CommunitySection = lazy(() => import('@/components/Home/CommunitySection'));
10+
const FeaturesAtGlanceSection = lazy(() => import('@/components/Home/FeaturesAtGlanceSection'));
11+
const FeaturesAndBenefitsSection = lazy(() => import('../components/Home/FeaturesAndBenefitsSection'));
12+
const ProjectSection = lazy(() => import('../components/Home/ProjectSection'));
13+
const Footer = lazy(() => import('@/components/Home/Footer'));
1314

1415
/**
1516
* Landing page that users first see upon visiting the website.
@@ -24,39 +25,42 @@ const Home: React.FC = () => {
2425
px: { sm: '10%', xs: 0 },
2526
}}
2627
>
27-
<Container
28-
maxWidth={false}
29-
disableGutters
30-
sx={{
31-
px: { sm: 6, xs: 2 },
32-
}}
33-
>
28+
<Container maxWidth={false} disableGutters sx={{ px: { sm: 6, xs: 2 } }}>
3429
<HeroSection />
30+
31+
{/* spacer */}
3532
<Box sx={{ height: { sm: '240px', xs: '64px' } }} />
36-
<FeaturesAtGlanceSection />
37-
<Box sx={{ height: { sm: '240px', xs: '64px' } }} />
38-
<FeaturesAndBenefitsSection />
39-
<Box sx={{ height: { sm: '240px', xs: '64px' } }} />
40-
<ProjectSection />
41-
<Box sx={{ height: { sm: '240px', xs: '64px' } }} />
42-
<CommunitySection />
43-
<Box sx={{ height: { sm: '240px', xs: '64px' } }} />
44-
{/* <TestimonialSection />
45-
<Box sx={{ height: { sm: '240px', xs: '64px' } }} />
46-
<SponsorsSection />
47-
<Box sx={{ height: { sm: '240px', xs: '64px' } }} /> */}
48-
<CallToActionSection />
49-
<Box sx={{ height: { sm: '240px', xs: '64px' } }} />
33+
34+
{/* single Suspense for all lazy sections */}
35+
<Suspense fallback={<Skeleton variant="rectangular" height={240} animation="wave" sx={{ mb: 4 }} />}>
36+
<FeaturesAtGlanceSection />
37+
<Box sx={{ height: { sm: '240px', xs: '64px' } }} />
38+
39+
<FeaturesAndBenefitsSection />
40+
<Box sx={{ height: { sm: '240px', xs: '64px' } }} />
41+
42+
<ProjectSection />
43+
<Box sx={{ height: { sm: '240px', xs: '64px' } }} />
44+
45+
<CommunitySection />
46+
<Box sx={{ height: { sm: '240px', xs: '64px' } }} />
47+
48+
<CallToActionSection />
49+
<Box sx={{ height: { sm: '240px', xs: '64px' } }} />
50+
</Suspense>
5051
</Container>
5152
</Box>
53+
5254
<Box
5355
sx={{
5456
backgroundColor: 'background.paper',
5557
color: 'text.primary',
5658
px: { sm: '48px', xs: 0 },
5759
}}
5860
>
59-
<Footer />
61+
<Suspense fallback={<Skeleton variant="rectangular" height={200} />}>
62+
<Footer />
63+
</Suspense>
6064
</Box>
6165
</>
6266
);

0 commit comments

Comments
 (0)