Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Lazy loading means waiting to load some parts of a webpage until they are needed.


On your Commerce Vision site, lazy loading of non-critical files can be enabled. This means that when a user views a page, these files won't load until they are visible on screenfiles of items that are not visible to them on screen will not load. Only those in the screen area, or what is called above the fold . Lazy loading is very often used for rich media files   

Image Removed

Here's an example of how lazy loading workswill load


Above the fold & Below the fold

Image Added





Panel

On this page:

Table of Contents


When to use lazy loading

The aim behind lazy loading is faster page load times. It is a tool you can use if one or more items on a webpage is slowing down loading. If there is no noticeable effect for the user, lazy loading may not be necessary.   


Often, lazy loading is enabled for images below the fold, especially large ones, when there are items to load, or for scripts that are non-critical on pageload. Here is a simple example. Suppose your home page has a

slider campaign, where only

banner slider with five different images. The user can only view one slide at a time

is viewed

. With lazy loading

on for the slider, an image file will not be loaded until that slide is visible to the user.  
Panel

On this page:

Table of Contents

Why use lazy loading?

The idea behind lazy loading is faster page load times. 

, each of the four image files not on screen remains unloaded until in view. The whole page will display faster to the user since they don't have to wait until all five images are loaded.  


By default, lazy loading of banners, images and product images is enabled by default for all websites. For greater control, objects in widgets that can be lazy loaded will have a toggle that can be switched on and off.


Here's an example for Lazy loading on the banner slider widget:

Lazy load images on Commerce Vision websitesImage Modified

Add


How to lazy

loading for

load images in HTML Snippet and Custom widgets

You've embedded added an image in an HTML Snippet or Custom widget and want to enable lazy loading, Here's a guide to do it.


You have an The image tag:

Code Block
languagexml
<img class="someClasses" src="/images/SomeImage.jpg"  style="someStyles">


 To add lazy loading, edit this the code:

Code Block
languagexml
<img class="cv-lazy someClasses" src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" data-src="/images/SomeImage.jpg"  style="someStyles">


Let's look at what has been done:

  1. cv-lazy: Add cv-lazy as a class to the attribute.
  2. src: update the src to a placeholder image. Use the gif format in this case so we don't get a layout shift.
  3. data-src: original src attribute changed to data-src to enable the original image to be lazy loaded.



Related help

Content by Label
showLabelsfalse
showSpacefalse
excludeCurrenttrue
cqllabel = "images" and title ~ "optimisation"

Content by Label
showLabelsfalse
showSpacefalse
excludeCurrenttrue
cqllabel = "content-management" and title ~ "optimise"