Echo.js is a very simple, lightweight and easy accessible jQuery lazy-loading image plugin that creates lazy-loading effect instantly to any images. It simply needs HTML5 data-* attributes to add lazy-loading for respective images. It also supported on background images, simply add the data-echo-background attribute to the element with the image URL.

Features:

How to use it:

1. Include the Javascript echo.min.js at the bottom of the web page.

<script src="path/to/echo.min.js"></script>

2. Add the basic HTML to the page.

<img src="img/blank.gif" alt="Photo" data-echo="img/photo.jpg">
<img src="img/blank.gif" alt="Photo" data-echo-background="img/photo.jpg">

3. Initialize the plugin and we're ready to go.

echo.init({
  offset: 100,
  throttle: 250
});

Callback

echo.init({
  callback: function(element, op) {
    if(op === 'load') {
      element.classList.add('loaded');
    } else {
      element.classList.remove('loaded');
    }
  }
});

.render()

echo.render();

Plugin's default options:

Name Default Type Description
offset 0 Number|String The offset option allows you to specify how far below, above, to the left, and to the right of the viewport you want Echo to begin loading your images. If you specify 0, Echo will load your image as soon as it is visible in the viewport, if you want to load 1000px below or above the viewport, use 1000.
offsetVertical offset's value Number|String The offsetVertical option allows you to specify how far above and below the viewport you want Echo to begin loading your images.
offsetHorizontal offset's value Number|String The offsetHorizontal option allows you to specify how far to the left and right of the viewport you want Echo to begin loading your images.
offsetTop offsetVertical's value Number|String The offsetTop option allows you to specify how far above the viewport you want Echo to begin loading your images.
offsetBottom offsetVertical's value Number|String The offsetBottom option allows you to specify how far below the viewport you want Echo to begin loading your images.
offsetLeft offsetVertical's value Number|String The offsetLeft option allows you to specify how far to left of the viewport you want Echo to begin loading your images.
offsetRight offsetVertical's value Number|String The offsetRight option allows you to specify how far to the right of the viewport you want Echo to begin loading your images.
throttle 250 Number|String The throttle is managed by an internal function that prevents performance issues from continuous firing of window.onscroll events. Using a throttle will set a small timeout when the user scrolls and will keep throttling until the user stops. The default is 250 milliseconds.
debounce true Boolean By default the throttling function is actually a debounce function so that the checking function is only triggered after a user stops scrolling. To use traditional throttling where it will only check the images every throttle milliseconds, set debounce to false.
unload false Boolean This option will tell echo to unload loaded images once they have scrolled beyond the viewport (including the offset area).
callback Function The callback will be passed the element that has been updated and what the update operation was (ie load or unload). This can be useful if you want to add a class like loaded to the element. Or do some logging.
Photo

HTML structure

<img src="path/to/blank.jpg" alt="Photo" data-echo="path/to/slide-1.jpg">

Script

echo.init({
  offset: 100,
  throttle: 250,
  unload: true
});
Photo

What is Lorem Ipsum?

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

Photo

What is Lorem Ipsum?

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.