Sign inSign up

Simple JavaScript Image Lazy Loading Library Echo.js

Add-ons
2026-07-25 23:39 2 views • 0 downloads 71.8KB
Simple JavaScript Image Lazy Loading Library Echo.js

Compatibility

Echo.js uses the HTML5 data attribute and needs to retrieve its value, so it is not compatible with IE6 or IE7. Although Lazy Load also uses the HTML5 data attribute, it retrieves the value differently.

Usage

1. Include the Files

1
<script src="js/echo.min.js"></script>

2、HTML

1
<img src="images/blank.gif" alt="pic" data-echo="img/pic.jpg" width="640" height="480">

blank.gif is a 1 x 1 pixel image used as the default image. The data-echo attribute specifies the actual image URL. It is also recommended to set the image width and height, either directly or through CSS. Otherwise, it seems that only images very far down the page will be lazy-loaded.

3、JavaScript

1
2
3
4
Echo.init({
offset: 0,
throttle: 0
});

Parameters

ParametersDescription
offsetThe number of pixels before an image enters the viewport at which it can be loaded
throttleThe delay in milliseconds before an image is lazy-loaded