延迟加载 (data-src2) Jssor Slider 未根据 w3 标准进行验证

Lazy loading (data-src2) Jssor Slider doesn't validate against w3 standards

Update: In short, my problem is neither with data-u, data-src2 nor with any of data-* attributes themselves. My problem is that using data-src2 attribute leaves my img tag without a src attribute which is a problem for .

当然不会 :) 但是我想知道是否有解决方法?

郑重声明,是的,我已经通过 questions mentioning about 验证:

我正在使用 jssor 的 jssor slider from jssor (I must thank him for the great work and his fast answers about the slider) with lazy loading images via data-src2 as documented in the reference page,w3 验证器显然抱怨图像没有 src 属性:

Element img is missing required attribute src.

我认为 pass html Validation (against w3c standards) page should contain one extra list item about validating lazy loading images. So, is there a way to work this around or should we wait for the next version as the author stated here 为:

I will enhance custom attribute handling for next version. at that time, you can use "data-u" instead of "u"

data-u 等自定义属性是 html5 的 w3c 标准。请尝试 html5 验证。

要使图像延迟加载,不应指定 src 属性。 html5 验证将为没有 src 属性的图像引发错误。 其实,没关系。我会说目前没有办法修复它。

这里的解决方案是设置一个 src 指向一个图像,该图像在延迟加载图像启动之前不会被注意到。典型的 1x1 像素透明 .png.gif 会成功的。

pixel.png 图片置于服务器某处后,您可以:

<img class="lazy" src="/img/pixel.png" data-src="/img/image-to-load.jpg" alt="" title=""/>

您的延迟加载将继续工作,您将恢复 html 验证。