Skip to content

Commit d7c37d1

Browse files
committed
Lazy load community images
1 parent 7fbcdf5 commit d7c37d1

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/components/ImageGallery.res

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ type mode =
33
| AutoFadeTransition(int) //milliseconds
44

55
@react.component
6-
let make = (~className="", ~imgClassName="", ~imgSrcs: array<string>, ~mode=NoAuto) => {
6+
let make = (
7+
~className="",
8+
~imgClassName="",
9+
~imgSrcs: array<string>,
10+
~imgLoading=?,
11+
~mode=NoAuto,
12+
) => {
713
let (index, setIndex) = React.useState(_ => 0)
814

915
React.useEffect(() => {
@@ -72,7 +78,7 @@ let make = (~className="", ~imgClassName="", ~imgSrcs: array<string>, ~mode=NoAu
7278
leave="transition-opacity duration-1000"
7379
leaveFrom="opacity-100"
7480
leaveTo="opacity-0">
75-
<img className=imgClassName src />
81+
<img className=imgClassName src loading=?imgLoading />
7682
</HeadlessUI.Transition>
7783
</div>
7884
<div className="flex space-x-2 mt-4"> {lineEls->React.array} </div>

src/layouts/LandingPageLayout.res

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ module OtherSellingPoints = {
445445
"/static/lp/community-2.jpg",
446446
"/static/lp/community-1.jpg",
447447
]}
448+
imgLoading=#lazy
448449
/>
449450
<h3 className="hl-3 text-gray-20 mt-4 mb-2">
450451
{React.string(`A community of programmers who value getting things done`)}

0 commit comments

Comments
 (0)