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 })