Home > Article > Web Front-end > Lazy loading of images
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 () { $('img').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!