下载地址

使用说明

0. 准备工作

下载jQuery和lazyload 插件(地址如上)

1. HTML

引入jQuery库和lazyload插件

    <div id="imagesContainer"></div>
<!--<img class="lazy" data-original="img/example.jpg" width="750" height="450">-->
<script src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js" type="text/javascript"></script>
<script src="../../lib/jquery.lazyload.js"></script>

2. 编写JavaScript

  $(function () {

             var images = [
'https://unsplash.ict/750/450?image=55', // 错误的地址;不会返回图片
'https://unsplash.it/750/450?image=155',
'https://unsplash.it/750/450?image=255',
'https://unsplash.it/750/450?image=355',
'https://unsplash.it/750/450?image=455',
'https://unsplash.it/750/450?image=555',
'https://unsplash.it/750/450?image=655',
'https://unsplash.it/750/450?image=5'
],
i = images.length,
$container = $('#imagesContainer'),
placerhold = '../layzr.js/placerhold.gif', // 图片未加载前显示的图片,若不设置,将默认显示灰色
imgtemp; while (i--) {
imgtemp = images.shift();
$container.append('<img class="lazy" src="'+placerhold+'" data-original="' + imgtemp + '" width="750" height="450">')
} $('img.lazy').lazyload({
effect: 'fadeIn' // 自定义显示效果(jQuery effect)
, failure_limit: 10
, threshold: 200 // 当距离图片还有200像素的时候,就开始加载图片。
, event: 'scroll'
}); // 自定义触发事件
// $("img.lazy").lazyload({ event: "click" });
});

3.  一些注意事项

3.1 必须设置图片的大小(行内样式或外部CSS都可以),否则插件可能无法达到理想的效果

3.2 可以设置倒计时,在指定的时间后加载图片

使用jQuery lazyload 实现图片延迟加载的更多相关文章

  1. jquery.lazyload 实现图片延迟加载jquery插件

    看到了淘宝产品介绍中,图片是在下拉滚动条时加载,这是一个很不错的用户体验.减少了页面加载的时间了,也减轻了服务器的压力,就查了下用JQuery..   什么是ImageLazyLoad技术 在页面上图 ...

  2. JQuery LazyLoad实现图片延迟加载-探究

    对于大量图片的网站,图片延迟加载是提高速度和性能的好方法. 目前图片延迟加载主要分两大块,一是触发加载(根据滚动条位置加载图片):二是自动预加载(加载完首屏后n秒后自动加载其他位置的图片).大体常用的 ...

  3. jquery.lazyload.js图片延迟加载

    转:http://www.jb51.net/article/50273.htm 这篇文章主要介绍了Jquery图片延迟加载插件jquery.lazyload.js的使用方法,需要的朋友可以参考下   ...

  4. jquery.lazyload.js图片延迟加载(懒加载)--转载

    一.插件介绍 jquery.lazyload.js 是一个用 JavaScript 编写的jQuery 插件. 它可以延迟加载长页面中的图片. 在浏览器可视区域外的图片不会被载入, 直到用户将页面滚动 ...

  5. jquery.lazyload.js 图片延迟加载

    当做网页的时候,特别是整个网页展示图片较多的时候,用到图片延迟效果是很好的 使用方法也非常简单. 1.在网页任何位置(一般是在</body>前面)加上如下代码(注意<script&g ...

  6. 使用jquery插件实现图片延迟加载技术(懒加载)

    有时我们看到一些大型网站,页面如果有很多图片的时候,当你滚动到相应的行时,当前行的图片才即时加载的,这样子的话页面在打开只加可视区域的图片,而其它隐藏的图片则不加载,一定程序上加快了页面加载的速度,对 ...

  7. jQuery Lazy Load 图片延迟加载

    基于 jQuery 的图片延迟加载插件,在用户滚动页面到图片之后才进行加载. 对于有较多的图片的网页,使用图片延迟加载,能有效的提高页面加载速度. 版本: jQuery v1.4.4+ jQuery ...

  8. 一个简单而实用的JQ插件——lazyload.js图片延迟加载插件

      前  言 Cherish 看多了炫酷的插件之后再来看这么一个小清新的东西,是不是突然感觉JQ插件感觉很友好了,简单强大最重要的是实用. 这篇文章将详细讲解一下lazyload.js的用法 lazy ...

  9. 使用jquery插件实现图片延迟加载--懒加载技术

    原文链接:http://www.cnblogs.com/lei2007/archive/2013/05/31/3110725.html 感谢作者.以下为原文,备忘仅供自己学习. 第一:lazyLoad ...

随机推荐

  1. Bitnami 2015

    WordPress WordPress is one of the world's most popular web publishing platforms for building blogs a ...

  2. 倍福TwinCAT(贝福Beckhoff)常见问题(FAQ)-人机界面如何设置页面跳转

    TC3中,可以点击某个按钮,改变所显示的视图,然后从你写好的页面中选择一个要跳过去的页面   当然,在跳过去的页面上再做一个按钮可以跳回主页面也是必须的     更多教学视频和资料下载,欢迎关注以下信 ...

  3. C++ 字符串转化成浮点型

    第一种: char  szString[] = "3.1415926535898"; double db1; db1 = atof(szString); printf(" ...

  4. java之生成jar包

    Java编写的application程序是否能够最终形成一个类似于exe一样的可执行文件,难道就只能用命令行运行?------------------------------------------- ...

  5. 通过Spring使用远程访问和web服务

    http://docs.huihoo.com/spring/zh-cn/remoting.html     Spring2 提供的remote包学习笔记

  6. L​i​n​u​x​关​闭​防​火​墙​命​令

    (1) 重启后永久性生效: 开启: chkconfig iptables on 关闭: chkconfig iptables off (2) 即时生效,重启后失效: 开启: service iptab ...

  7. c++ two classes as each others' friends

    In this case, Box need access to Cup.func, AND Cup need access to Box.func, both of which are privat ...

  8. SQL数据库 CRUD

    1.删除表 drop  table +表名 2.修改表 alter  table+表名+ add(添加)+列名+ int(类型) alter  table+表名+ drop(删除)+column(列) ...

  9. strust2 和 hibernate的整合------登录的实现

    初步认识了struts2,并与hibernate进行整合,完成了一个登录的案例,下面贴源码 1.实体类User public class User { private Integer id; priv ...

  10. Tree UVA - 548 已知中序遍历和后序遍历,求这颗二叉树。

    You are to determine the value of the leaf node in a given binary tree that is the terminal node of ...