Home  >  Article  >  Web Front-end  >  Lazy loading of images

Lazy loading of images

炎欲天舞
炎欲天舞Original
2017-08-04 14:54:592143browse

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" />
}

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>

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!

Statement:
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