Simple JavaScript Image Lazy Loading Library Echo.js

Add-ons
2026-07-25 23:39 2 次浏览 • 0 次下载 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


星河码客

发现和分享优质开源项目,传承互联网精神,为开发者服务。

关于本站

联系我们

微信/广告合作:ITcloub (备注星河码客)

免责声明:本站资源版权归原作者所有,仅供学习与交流。如有侵权,请通过「关于我们 - 侵权投诉」联系删除。

Powered by Nuxt · Deployed on Cloudflare