(viewable area loading) picture lazy loading implementation principle

Source: Internet
Author: User

Reference article:http://www.cnblogs.com/xiaohuochai/p/4859485.htmlhttp://www.cnblogs.com/xiaohuochai/p/4859899.html http://www.cnblogs.com/vajoy/p/4263291.html Defined

Picture delay loading is also known as lazy loading, loading some pictures when loading pictures late or qualifying certain conditions, usually for pages with more pictures. You can reduce the number of requests or delay the number of requests to optimize performance.

Presentation Form

"1" delay load, load delay using settimeout or setinterval, if the user leaves before loading, nature will not load.
The "2" condition loads, meets certain conditions, or triggers certain conditions before the asynchronous load begins.
"3" visual area loading, just load the user can see the area, the main monitoring scroll bar to achieve, generally from the user to see the bottom edge is very close to start loading, so as to ensure that the user pull down when the picture is connected, there will not be too long a pause.

Basic steps

The pictures in the "1" page are set to the same picture
"2" adds the Data-original = "Img/test.jpg" attribute to the picture, saving the real address of the picture
"3" when certain conditions are triggered, the SRC attribute of the picture that automatically changes the area is the real address

Application

"Click the button to display the picture"

<! DOCTYPE html>

"Show picture in Visual area"

<! DOCTYPE html>

"Effect Show"

(viewable area loading) picture lazy loading implementation principle

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.