-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(feat): Add lazy loading for images #784
base: main
Are you sure you want to change the base?
(feat): Add lazy loading for images #784
Conversation
@senthil-k8s i would not use this ,please try to create a custom lazy load component with Image(component) of nextjs. it can be a simple component with a state like:
Just search little bit online for optimizations etc |
@siinghd Using the Image component of Next.js requires width and height, in the existing img tag in our codebase, I couldn't find the specified width and height. Shall I use the Image component of Next.js or the default img tag? Demo: https://www.loom.com/share/d622a54442214bd3b6e33bacdb43a4a6 |
@senthil-k8s Use nextjs and provide width and height suitable |
@siinghd Done! |
…azy-load-image
import Image from 'next/image'; | ||
import React, { useState, useRef, useEffect } from 'react'; | ||
|
||
const registerObserver = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this complex logic? NextJs Image its already loas images like that...
what i was saying is until the image isnt loaded show the skeleton
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to observe the viewport by writing custom logic. Utilizing this LazyLoadImage component, we can customize our own skeleton, and styling effect.
PR Fixes:
This PR introduces LazyLoadImage, a library that enables lazy loading of images using react-lazy-load-image-component. Aims to improves performance by delaying image loading until they're needed, reducing initial page load times and conserving bandwidth
Resolves #783
Checklist before requesting a review