【发布时间】:2020-07-24 19:00:55
【问题描述】:
Chrome 81、FF 75(今天最新)
Chrome 原生图像延迟加载仅在 iframe 内有效。为什么?在 FF 中效果很好
page1.htm(延迟加载在 Chrome 中不起作用,但在 FF 中很好):
<p style="margin-bottom: 1000px;">Please scroll down. The image is below the viewport.</p>
<p style="margin-bottom: 1000px;">Please scroll down. The image is below the viewport.</p>
<img src="https://wallpaperplay.com/walls/full/5/e/a/218959.jpg" loading="lazy">
page2.htm(通过 iframe 进行延迟加载在 Chrome 和 FF 中都有效):
<iframe src="page1.htm">
这是 Chrome 的错误吗?在FF中效果很好
(您可以通过滚动和开发者工具 -> 网络检查图像延迟加载)
【问题讨论】:
-
编辑您的问题。您可以使用 sn-p 工具并添加比代码更好的功能。阅读:stackoverflow.com/help/how-to-ask
-
我没有使用代码 sn-p,因为它在 iframe 中运行,这可能会误导读者,因为我的问题/问题是 iframe 相关的
标签: html image google-chrome iframe lazy-loading