Image Lazy Load: Open-Source plug-ins (jQuery) that Load images at a time ),

Source: Internet
Author: User

Image Lazy Load: Open-Source plug-ins (jQuery) that Load images at a time ),

The image delayed loading technology is very practical for large-traffic websites. Currently, images are widely used on websites. If they are not processed, they will put a great deal of pressure on servers and bandwidth. By rendering only images in the visible area of the current user, this greatly reduces the number of website requests and network bandwidth resources.

Unveil

This is a lightweight image loading component.

Supports modern browsers and IE7 +, with nearly 3 k stars on Github (follow)

Use

General Image

 

For devices that support retina (retina screen)

 

Application

$(document).ready(function() {  $("img").unveil();});

Callback supported

$("img").unveil(200, function() {  $(this).load(function() {    this.style.opacity = 1;  });});

Manual triggering is supported.

$("img").trigger("unveil");
Jquery_lazyload

Images of large websites can be loaded at a time delay, and rendered when they are rolled to a region. There are 4 K notes on Github.

Use

Reference jQuery and lazyload. js

<script src="jquery.js" type="text/javascript"></script><script src="jquery.lazyload.js" type="text/javascript"></script>

Images to be loaded with latency

 

Application

$(function() {    $("img.lazy").lazyload();});
Echo

An independent emblem JavaScript image loading library with delay. It does not rely on jQuery, and only 2 K after compression.

Supports IE8 +

Use

<Body>  <script src = "dist/echo. js "> </script> <script> echo. init ({offset: 100, throttle: 250, unload: false, callback: function (element, op) {console. log (element, 'has been', op + 'ed')}; // echo. render (); // manually triggered call </script> </body>
Layzr. js

An Image Lazy Loading component just released a few days ago. It is small, fast, and has no dependency (not dependent on jQuery). It also supports retina devices.

<script src="layzr.min.js"></script><script>var layzr = new Layzr({  attr: 'data-layzr',  retinaAttr: 'data-layzr-retina',  threshold: 0,  callback: null });</script> 
Update

So, how can I turn a bunch of img in HTML into data-src on the server? In fact, it is very simple. Just a few lines of regular expressions. For example, in node. js, the img src can be converted to data-src (you can directly press F12 to run in the browser Console)

Var html = 'html = HTML that contains . replace (/] +>/g, function (imgstr, idx) {imgstr = imgstr. replace ('src = ', 'Data-src =') return imgstr })

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.