이미지를 preload 해주는 방식을 통해 개선할 수 있다고 합니다.
The Largest Contentful Paint (LCP) metric looks at the loading performance of your page. LCP measures the time it takes to get the largest element on the page visible within the viewport. This could be a large text block, video, or image that takes up the primary real estate on the page.
<Image
src={`${article?.thumbnailUrl}`}
alt={`${article?.thumbnailUrl} 이미지`}
priority={true}
width={100}
height={100}
className='item-card-img'
/>
위에서 priority 속성을 true로 설정해줍니다.
...로 끝나면 좋겠지만!
추가적으로 next.config.js에서 whitelist 추가를 해줘야 합니다. (next 14.1.0 기준)
const nextConfig = {
// ....
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'avatars.githubusercontent.com',
},
],
remotePatterns: [
{
protocol: 'https',// 프로토콜
hostname: 'roadmaker-images.s3.amazonaws.com', //이미지 fetch 해오는 주소
// port: '',
// pathname: '/account123/**', 특정 버킷 설정
},
],
},
// ....
};
module.exports = nextConfig;