Home > Web Front-end > JS Tutorial > Lazy loading of images

Lazy loading of images

炎欲天舞
Release: 2017-08-04 14:54:59
Original
2171 people have browsed it

Background: Sometimes we don’t need to load all the pictures when we open a page. We hope that they will be loaded only when the pictures are to be displayed on the page. Taobao is a good example. When we slide the page, which picture should we slide to? Only one picture will be loaded, which saves the user's mobile phone traffic.

Upload the code


@for (int i = 3; i < 22; i++)
{
    <img src="/Content/img/d.jpg" src="/Content/img/WeiXin/course/5/幻灯片@(i).JPG" />
}
Copy after login

Only set src as the image address. src is the image. The style when loading


 <script src="~/Scripts/jquery.lazyload.min.js"></script>
    <script>
        $(function () {
            $(&#39;img&#39;).lazyload();
        })    
 </script>
Copy after login

is not very simple!

The above is the detailed content of Lazy loading of images. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template