Lazy Loading Images With Intersection Observer in React
Creating a Gatsby Image style custom React component
Lazy loading is a common performance optimization technique followed by almost all asset-heavy websites. We often come across web pages where a blurred version of the image loads up and is then followed up with a high-resolution image. Although the total time taken to load up the content is long, it has a perceivable effect on user experience.
This entire interaction is a three-step process:
If you have ever used Gatsby, then you would have come across a** Gatsby Image** component that does the same for you. In this article, we will implement a similar component that can be used as a generic component. Although Gatsby Image does a lot more than blur and load images, we will focus on the simple thing:
The first step to building the entire thing is to create a layout of your image components.
This part is pretty straightforward. For the purpose of the article, we will dynamically iterate over a set of images and render an ImageRenderer
component.
#react #javascript #programming