Image Lazy Load: Those open source plug-ins (jQuery) that delay loading images

伊谢尔伦
Release: 2016-11-29 09:17:37
Original
1126 people have browsed it

The image delayed loading technology is very practical for websites with high traffic. Currently, images are widely used in websites. If they are not processed, they will put great pressure on the server and bandwidth. By only rendering images in the area visible to the current user, you can greatly reduce the number of website requests and reduce network bandwidth resources.

 unveil

 This is a very lightweight short-time image loading component

It supports modern browsers and IE7+, and there are nearly 3K stars (follows) on Github

 Use

General pictures

Copy after login

 For support Retina (retina screen) device

Copy after login

Application

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

Support callback

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

Support manual trigger

$("img").trigger("unveil");
Copy after login

jquery_lazyload

Can delay loading of images of large websites, and then render when scrolling to the area. There are 4K followers on Github.

Use

Reference jQuery and lazyload.js

 
Copy after login

Images that need to be delayed loaded

Copy after login

Apply

$(function() { $("img.lazy").lazyload(); });
Copy after login

echo

An independent logo-type JavaScript image delayed loading library. Does not rely on jQuery, only 2K after compression.

  Support IE8+

Use

 Photo   
Copy after login

layzr.js

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

  
Copy after login

Updated

So, how to let the server convert a bunch of img in HTML into data-src? In fact, it is very simple, just a few lines of regular rules are enough. For example, in node.js, you can convert img's src into data-src (you can directly press F12 to run it in the browser's Console)

var html = '包含  的HTML' html = html.replace(/]+>/g, function(imgstr, idx) { imgstr = imgstr.replace(' src=', ' data-src=') return imgstr })
Copy after login


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!