Skip to content

Commit

Permalink
Optimize page LCP
Browse files Browse the repository at this point in the history
  • Loading branch information
Chalarangelo committed Dec 18, 2023
1 parent e71d9b4 commit e14ff2e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/PreviewList.astro
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const { contentItems, largeImages = false } = Astro.props;
src={contentItem.cover}
srcset={contentItem.coverSrcset}
alt=''
height={largeImages ? '300' : '200'}
width='400'
height={largeImages ? '240' : '180'}
width='360'
loading='lazy'
/>
<article>
Expand Down
5 changes: 5 additions & 0 deletions src/styles/components/_hero.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
img {
border-radius: var(--border-radius-medium);

// Optimize image for LCP, by defining a height and aspect ratio.
height: 240px;
aspect-ratio: 1;
object-fit: cover;

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
// Apply this effect only when hover is supported and the user has not
// requested reduced motion. It's just for show, so it's not important.
Expand Down

0 comments on commit e14ff2e

Please sign in to comment.