Skip to content

Reduce landing page load times and network usage by losslessly optimising & lazy-loading images #1061

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

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Lazy load community images
  • Loading branch information
mediremi committed Jun 29, 2025
commit d7c37d1b20b309a5a4f4eee14203b43a2887e857
10 changes: 8 additions & 2 deletions src/components/ImageGallery.res
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ type mode =
| AutoFadeTransition(int) //milliseconds

@react.component
let make = (~className="", ~imgClassName="", ~imgSrcs: array<string>, ~mode=NoAuto) => {
let make = (
~className="",
~imgClassName="",
~imgSrcs: array<string>,
~imgLoading=?,
~mode=NoAuto,
) => {
let (index, setIndex) = React.useState(_ => 0)

React.useEffect(() => {
Expand Down Expand Up @@ -72,7 +78,7 @@ let make = (~className="", ~imgClassName="", ~imgSrcs: array<string>, ~mode=NoAu
leave="transition-opacity duration-1000"
leaveFrom="opacity-100"
leaveTo="opacity-0">
<img className=imgClassName src />
<img className=imgClassName src loading=?imgLoading />
</HeadlessUI.Transition>
</div>
<div className="flex space-x-2 mt-4"> {lineEls->React.array} </div>
Expand Down
1 change: 1 addition & 0 deletions src/layouts/LandingPageLayout.res
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ module OtherSellingPoints = {
"/static/lp/community-2.jpg",
"/static/lp/community-1.jpg",
]}
imgLoading=#lazy
/>
<h3 className="hl-3 text-gray-20 mt-4 mb-2">
{React.string(`A community of programmers who value getting things done`)}
Expand Down