【发布时间】:2021-01-06 17:00:43
【问题描述】:
所以每次我运行灯塔评估时,它都会告诉我“推迟屏幕外图像”,现在,他们建议使用他们的脚本并像这样设置图像:
<img data-src="images/flower3.png" class="lazyload" alt="">
这就是我所拥有的:
<picture>
<source sizes="(min-width:1025px) 25vw,(min-width:0px) 100vw"
srcset="https://thumbor.mypage/YiZprbZxOEdzieJbcj8ZnIKIrE4=/640x0/https%3A%2F%2Fmyimage.jpg 640w,...">
<img alt="" sizes="(min-width:1025px) 25vw,(min-width:0px) 100vw"
data-object-fit="cover"
class=" ls-is-cached lazyloaded"
data-src="https://thumbor.mypage/yoi8S4dSPBIU5ekNg6x7NvFFFPM=/320x0/https%3A%2F%2Fmyimage.jpg"
srcset="https://thumbor.mypage/YiZprbZxOEdzieJbcj8ZnIKIrE4=/640x0/https%3A%2F%2Fmyimage.jpg 640w,https://thumbor.mypage/qoSnHcwy_fuA8C2gJaKnxnCJ00A=/1024x0/https%3A%2F%2Fmyimage.jpg 1024w,...">
</picture>
如您所见,我检查了他们要求的两件事以匹配正确的代码:lazyload 类和 data-src 属性,也许我遗漏了一些东西,但由于某种原因,它只失败了几个图片。请帮忙!
【问题讨论】:
标签: html lighthouse