类别:FRONTEND / 前端 / 日期:2020-05-15 / 浏览:1548 / 评论:0
懒得翻译了,直接帖原文... 简单来说就是一个占用非常小的,针对图片的屏外延迟加载的JS脚本,SEO首选。但是相对的因为小巧,自然就不会有过渡动画,图片加载的时候就是传统由上到下的显示方式。
lazysizesis a fast (jank-free), SEO-friendly and self-initializing lazyloader for images (including responsive images ``picture``/``srcset``), iframes, scripts/widgets and much more. It also prioritizes resources by differentiating between crucial in view and near view elements to make perceived performance even faster.
It may become also your number one tool to integrate responsive images. It can automatically calculate the ``sizes`` attribute for your responsive images, it allows you to share media queries for your ``media`` attributes with your CSS, helping to separate layout (CSS) from content/structure (HTML) and it makes integrating responsive images into any environment really simple. It also includes a set of optional plugins to further extend its functionality.
1、Download the [lazysizes.min.js script](http://afarkas.github.io/lazysizes/lazysizes.min.js) and include lazysizes in your webpage. 2、<script src="lazysizes.min.js" async=""></script> 3、<img data-src="image.jpg" class="lazyload" />
发表评论 / 取消回复