Lazy Load Images In Next.js - Dev Hints

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
if your website takes a long time to load you could be losing potential customers or visitors one thing that can be done to avoid this is to load images only when a user sees them lazy loading images isn't too difficult to implement It's actually an attribute that comes out of the box with the HTML image tag and the iframe tag this loading attribute set to Lazy will prevent the browser from loading resources until the user gets to it by scrolling or some other interaction to prevent any layout shifts it's recommended to add a width and height property to the image via CSS or inline attributes it's also recommended to only lazy load images that don't contribute to the largest content for paint LCP for short these are images like banner and hero ones with the cloud image component lazy loading is enabled by default so you don't have to do anything which means requests for images are never made if a user never sees them this also helps you save on bandwidth which means you're only making calls that are necessary if you have an LCP image then you can eagerly load it by adding the priority attribute to the cloud image component just like you would for the next image component so for this header image adding the priority attribute will tell the browser that this is high priority this could cause performance issues if this is not used for an LCP image so be sure to use this sparingly now that you know all about lazy loading in the next video we're going to learn about another optimization feature from the cloud image component called responsive sizing
Info
Channel: Cloudinary
Views: 1,786
Rating: undefined out of 5
Keywords: lazy load next js, lazy load images nextjs, lazy load images, image optimization, image optimization next js, lazy load cloudinary, next cloudinary, nextjs cloudinary, nextjs image loading, nextjs image lazy loading, nextjs image performance, next js performance optimization
Id: 8cqiKjiGKOo
Channel Id: undefined
Length: 1min 55sec (115 seconds)
Published: Tue Jan 02 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.