Notice
Recent Posts
Recent Comments
Link
프로그래밍 공부방
[Next.js] Image with src "..." was detected as the Largest Contentful Paint(LCP) 본문
⚠️경고 내용: Image with src "..." was detected as the Largest Contentful Paint(LCP)
Nextjs의 Image를 사용하던 도중에 위와 같은 경고가 발생했습니다.
🤷♀️Why?🤷♀️
LCP로 감지된 이미지인데 priority 속성을 사용하지 않았기 때문입니다.
✨해결 방법
Image에 priority={true}를 추가해서 해결했습니다.
<Image priority={true} loader={externaImageLoader} src={image} className="w-20 h-20 bg-gray-400 rounded-md" width={80} height={80} layout="fixed"/>
priority를 true로 설정할 경우 해당 이미지를 높은 우선순위로 생각하기 때문에 미리 로드됩니다.
또한 priority를 사용하는 이미지에 대해 지연 로딩이 자동으로 비활성화됩니다.
priority 속성을 사용해야하는 경우는 언제일까요?
👉 LCP로 감지된 이미지의 경우에 priority 속성을 사용해야합니다.
- LCP(lLargest Contentful Paint)란? 페이지의 로딩 성능을 확인할 수 있는 지표입니다.
- LCP는 뷰포트 내에서 볼 수 있는 페이지에서 가장 큰 요소를 가져오는 데 걸리는 시간을 측정합니다.
'프론트엔드 > Next.js' 카테고리의 다른 글
[Next.js] ReferenceError: localStorage is not defined 에러 (0) | 2023.07.01 |
---|---|
[Next.js] 자식 컴포넌트에서 부모 컴포넌트로 값 보내주기 (0) | 2023.07.01 |
[Next.js] Error: Invalid src prop (...) on `next/image`, hostname "..." is not configured under images in your `next.config.js` (0) | 2023.06.29 |
[Next.js] 당근마켓 프로젝트 성능 최적화 과정1 - 상품 출력하는 작업 (0) | 2023.06.27 |
[Next.js] form enter키 클릭 시에 새로고침 막기 (0) | 2023.06.24 |