Lazy Loading

Lazy loading is a type of programming technique that delays loading resources until they are really needed.

For example, a webpage in which images are not loaded until the user scrolls down to that location in that page. Lazy loading is also used in the web and in some software programs as well for mobile and desktop applications.

Lazy Loading Web

Lazy loading of images on a webpage can also speed up the load time of the page as the browser does not need to load the images which are not visible to the user.

As the user scrolls into the page, then images also load dynamically. This process is accomplished using JavaScript that detects the position of each image and also determines whether it is in the viewable area of ​​the browser window.

If the user scrolls down to an image, then JavaScript again requests the web server for the resource and then that image is displayed in the page. If the user does not scroll down at all, then the image is not loaded at all.

It is possible to delay loading other resources such as JavaScript files, CSS , and even HTML .

For example, a web developer determines which CSS styles are needed in a webpage for “above-the-fold” content, or the height of the content viewable for a typical browser window.

The developer implements all of these as ” inline styles ,” or styles that are defined under the HTML of the webpage. JavaScript is used to load additional CSS once the page is loaded or once the user starts scrolling.

Lazy loading video is also very popular on the web. This is much more effective because video files are usually the largest resources that are loaded in a webpage. Instead of sending the entire video to the client’s device, the web server sends only some part of the video while the user is watching it.

Popular video sharing websites such as YouTube and Vimeo use lazy loading to reduce their bandwidth and prevent users from downloading more video content than they actually need.

This is very helpful for those users who use metered Internet connections, such as mobile data plans.

When the lazy loading process of a video is going on, it is very common that a few seconds or a few minutes of that video are already loaded, compared to the current point of that video. This video data is saved in a buffer, which helps videos to play smoothly when the Internet connection is not consistent.

Lazy Loading Software Programs में

While lazy loading has become very popular in the web, it has been used for a long time in software development.

For example, an operating system only displays thumbnail images, visible icons in a folder.

At the same time, an image viewing program also only loads the visible images in a photo library. With this, they use very low memory and improve the application performance simultaneously because the programs do not load unnecessary data in such a way.

« Back to Wiki Index