Image with src "/images/logo.png" was detected as the Largest Contentful Paint (LCP) #48255
-
SummaryI am trying to do a project in Next.13 and Typescript. I have created a component named
But I am getting this warning.
I looked into the documentation but could not understand properly. How can remove this error? Additional informationNo response ExampleNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
What this is telling you is that you have a large image that is not being loaded optimally.
With images, and other resources, we can use a technique called pre-loading. As soon as the browser hits the preload link, it'll get that resource and continue processing the HTML for the page, https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel/preload In Next.js, the next/image component has a
"use client";
import Image from "next/image";
import { useRouter } from "next/navigation";
const Logo = () => {
const router = useRouter();
return (
<Image
alt="logo"
height="100"
width="100"
priority // or priority={true}
className="
hidden
md:block
cursor-pointer
"
src="/images/logo.png"
/>
);
};
export default Logo; Do remember that this is not an error, but warning, hinting you in the right direction. |
Beta Was this translation helpful? Give feedback.
What this is telling you is that you have a large image that is not being loaded optimally.
With images, and other resources, we can use a technique called pre-loading. As soon as the browser hits the preload link, it'll get that resource and continue processing the HTML for the page, https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel/preload
In Next.js, the next/image component has a
priority
prop, which you can activate to trigger the preload of the resource, https://nextjs.org/docs/api-re…