Skip to content

Commit

Permalink
added eager and lazy loading
Browse files Browse the repository at this point in the history
  • Loading branch information
jNembhard committed Nov 1, 2023
1 parent 3ad4616 commit 60fe78f
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/components/molecules/AboutCard/AboutCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ const StyledCardText = styled(Typography)(({ isdark }: { isdark: string }) => ({
type AboutCardProp = {
aboutID: string;
isdark: string;
pictureloading: boolean;
};

const AboutCard = ({ aboutID, isdark }: AboutCardProp) => {
const AboutCard = ({ aboutID, isdark, pictureloading }: AboutCardProp) => {
const isBreakpoint767 = useMediaQuery("(min-width: 767px)");
const isBreakpoint1024 = useMediaQuery("(min-width: 1024px)");

Expand Down Expand Up @@ -98,6 +99,7 @@ const AboutCard = ({ aboutID, isdark }: AboutCardProp) => {
process.env.REACT_APP_CLOUDFRONT_ENDPOINT +
images.heroPatternMobile
}
loading={pictureloading ? "eager" : "lazy"}
alt=""
/>
</Box>
Expand Down
1 change: 1 addition & 0 deletions src/components/molecules/DesignHeader/DesignHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const DesignHeader = ({ designID }: DesignHeaderProp) => {
component="img"
src={process.env.REACT_APP_CLOUDFRONT_ENDPOINT + images.bgPattern}
sx={{ ...designHeaderStyles.bgImage }}
loading="eager"
alt=""
/>
<Box sx={{ ...designHeaderStyles.textContainer }}>
Expand Down
2 changes: 2 additions & 0 deletions src/components/molecules/Keypoint/Keypoint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ const Keypoint = ({ calloutID, image, title, description }: ICallout) => {
process.env.REACT_APP_CLOUDFRONT_ENDPOINT +
"assets/shared/desktop/bg-pattern-small-circle.svg"
}
loading="lazy"
alt=""
/>
</Box>
<Box>
<img
src={process.env.REACT_APP_CLOUDFRONT_ENDPOINT + image}
loading="lazy"
alt={title}
/>
</Box>
Expand Down
2 changes: 2 additions & 0 deletions src/components/molecules/Maps/Maps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const Maps = () => {
process.env.REACT_APP_CLOUDFRONT_ENDPOINT +
location.images.desktop
}
loading={hashID === "canada" ? "eager" : "lazy"}
alt={location.title}
/>
</picture>
Expand All @@ -87,6 +88,7 @@ const Maps = () => {
process.env.REACT_APP_CLOUDFRONT_ENDPOINT +
"assets/shared/desktop/bg-pattern-three-circles.svg"
}
loading={hashID === "canada" ? "eager" : "lazy"}
alt=""
/>
</Box>
Expand Down
1 change: 1 addition & 0 deletions src/components/molecules/Place/Place.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const Place = ({ LocationID, images, title, slug }: IPlace) => {
process.env.REACT_APP_CLOUDFRONT_ENDPOINT +
"assets/shared/desktop/bg-pattern-small-circle.svg"
}
loading="lazy"
alt=""
/>
</Box>
Expand Down
1 change: 1 addition & 0 deletions src/components/molecules/Product/Product.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const Product = ({ description, image, title }: IProduct) => {
alt={description}
sx={{ ...productStyles.cardMedia }}
image={process.env.REACT_APP_CLOUDFRONT_ENDPOINT + image}
loading="lazy"
/>
<CardContent sx={{ ...productStyles.cardContent }}>
<Typography
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const PrimeDesign = (design: PrimeDesignProp) => {
/>
<Box
component="img"
loading="lazy"
sx={{ ...primeStyles.images }}
src={process.env.REACT_APP_CLOUDFRONT_ENDPOINT + images.mobile}
alt={title}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const SubDesign = (design: SubDesignProp) => {
/>
<Box
component="img"
loading="lazy"
sx={{ ...subStyles.images }}
src={process.env.REACT_APP_CLOUDFRONT_ENDPOINT + images.mobile}
alt={title}
Expand Down
2 changes: 2 additions & 0 deletions src/components/organisms/HeroCTA/HeroCTA.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const HeroCTA = () => {
<Box>
<Box
sx={{ ...heroStyles.bgImage }}
loading="eager"
component="img"
src={
process.env.REACT_APP_CLOUDFRONT_ENDPOINT +
Expand All @@ -71,6 +72,7 @@ const HeroCTA = () => {
/>
<Box
sx={{ ...heroStyles.image }}
loading="eager"
component="img"
src={designoPhoneImg}
alt="designo phone"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const ContactTemplate = () => {
<Box sx={{ ...contactTemplateStyles.wrapper }}>
<Box component="picture" sx={{ ...contactTemplateStyles.image }}>
<source media="(min-width: 767px)" srcSet={bgContactDesktop} />
<img src={bgContactMobile} alt="" />
<img src={bgContactMobile} alt="" loading="eager" />
</Box>
<ContactDescription />
<Form />
Expand Down
6 changes: 3 additions & 3 deletions src/pages/About.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ const About = () => {
type="webapp"
/>
<Box sx={{ ...aboutWrapper }}>
<AboutCard aboutID={"about-1"} isdark="true" />
<AboutCard aboutID={"about-2"} isdark="false" />
<AboutCard aboutID={"about-1"} isdark="true" pictureloading={true} />
<AboutCard aboutID={"about-2"} isdark="false" pictureloading={false} />
<Places />
<AboutCard aboutID={"about-3"} isdark="false" />
<AboutCard aboutID={"about-3"} isdark="false" pictureloading={false} />
</Box>
</>
);
Expand Down

0 comments on commit 60fe78f

Please sign in to comment.