@@ -29,9 +29,9 @@ import CodeModal from "@/components/CodeModal"
29
29
import CommunityEvents from "@/components/CommunityEvents"
30
30
import HomeHero from "@/components/Hero/HomeHero"
31
31
import { Image } from "@/components/Image"
32
+ import LazyLoadComponent from "@/components/LazyLoadComponent"
32
33
import MainArticle from "@/components/MainArticle"
33
34
import PageMetadata from "@/components/PageMetadata"
34
- import StatsBoxGrid from "@/components/StatsBoxGrid"
35
35
import TitleCardList from "@/components/TitleCardList"
36
36
import Translation from "@/components/Translation"
37
37
@@ -70,6 +70,29 @@ import merge from "@/public/images/upgrades/merge.png"
70
70
import robotfixed from "@/public/images/wallet-cropped.png"
71
71
import ethereum from "@/public/images/what-is-ethereum.png"
72
72
73
+ // lazy loaded components
74
+ const Codeblock = lazy ( ( ) =>
75
+ Promise . all ( [
76
+ import ( "@/components/Codeblock" ) ,
77
+ // Add a delay to prevent the skeleton from flashing
78
+ new Promise ( ( resolve ) => setTimeout ( resolve , 1000 ) ) ,
79
+ ] ) . then ( ( [ module ] ) => module )
80
+ )
81
+ const StatsBoxGrid = lazy ( ( ) => import ( "@/components/StatsBoxGrid" ) )
82
+
83
+ const Skeleton = ( ) => (
84
+ < Stack px = { 6 } pt = "2.75rem" h = "50vh" >
85
+ < SkeletonText
86
+ mt = "4"
87
+ noOfLines = { 6 }
88
+ spacing = { 4 }
89
+ skeletonHeight = "1.4rem"
90
+ startColor = "body.medium"
91
+ opacity = { 0.2 }
92
+ />
93
+ </ Stack >
94
+ )
95
+
73
96
const SectionHeading = ( props : HeadingProps ) => (
74
97
< Heading
75
98
lineHeight = { 1.4 }
@@ -225,27 +248,6 @@ export const getStaticProps = (async ({ locale }) => {
225
248
}
226
249
} ) satisfies GetStaticProps < Props >
227
250
228
- const CodeblockSkeleton = ( ) => (
229
- < Stack px = { 6 } pt = "2.75rem" h = "50vh" >
230
- < SkeletonText
231
- mt = "4"
232
- noOfLines = { 6 }
233
- spacing = { 4 }
234
- skeletonHeight = "1.4rem"
235
- startColor = "body.medium"
236
- opacity = { 0.2 }
237
- />
238
- </ Stack >
239
- )
240
-
241
- const Codeblock = lazy ( ( ) =>
242
- Promise . all ( [
243
- import ( "@/components/Codeblock" ) ,
244
- // Add a delay to prevent the skeleton from flashing
245
- new Promise ( ( resolve ) => setTimeout ( resolve , 1000 ) ) ,
246
- ] ) . then ( ( [ module ] ) => module )
247
- )
248
-
249
251
const HomePage = ( {
250
252
communityEvents,
251
253
metricResults,
@@ -561,7 +563,7 @@ const HomePage = ({
561
563
setIsOpen = { setModalOpen }
562
564
title = { codeExamples [ activeCode ] . title }
563
565
>
564
- < Suspense fallback = { < CodeblockSkeleton /> } >
566
+ < Suspense fallback = { < Skeleton /> } >
565
567
< Codeblock
566
568
codeLanguage = { codeExamples [ activeCode ] . codeLanguage }
567
569
allowCollapse = { false }
@@ -584,7 +586,17 @@ const HomePage = ({
584
586
< Translation id = "page-index:page-index-network-stats-subtitle" />
585
587
</ SectionDecription >
586
588
</ ContentBox >
587
- < StatsBoxGrid data = { metricResults } />
589
+
590
+ < LazyLoadComponent
591
+ component = { StatsBoxGrid }
592
+ fallback = { < Skeleton /> }
593
+ componentProps = { { data : metricResults } }
594
+ intersectionOptions = { {
595
+ root : null ,
596
+ rootMargin : "500px" ,
597
+ threshold : 0 ,
598
+ } }
599
+ />
588
600
</ GrayContainer >
589
601
< Divider mb = { 16 } mt = { 16 } w = "10%" height = "0.25rem" bgColor = "homeDivider" />
590
602
< CommunityEvents events = { communityEvents } />
0 commit comments