2
votes

I just implemented the new native lazy loading of chrome 76 in some images. It consists simply in adding the attribute loading="lazy" to images.

ex:

<img src="#url" width="380" height="285" alt="altexample" loading="lazy">

But for my surprise w3c is returning the following error:

"Error: Attribute loading not allowed on element img at this point."

Some documentation:

Chrome 76 release notes https://www.chromestatus.com/feature/5645767347798016

Implementation example https://www.searchenginejournal.com/google-chrome-will-soon-support-lazy-loading-at-the-browser-level/321211/

Anyone with the same problem? Thank you

2

2 Answers

1
votes

I could mainly think about that the spec itself (https://github.com/whatwg/html/pull/3752) is still in draft state, as things are still being finalized. So maybe the validator is only considering „stable“ or at least „not in draft state anymore“ features to be validated correctly (or it just hasn‘t been implemented ;-) maybe for the same reasons as stated before).

0
votes

As of today (2021), lazy-loading is supported in all major browsers and is now a living standard (see: img attributes on MDN and Lazy loading attributes on the WTAHWG specs) and W3C's HTML validator does not report any errors.

The Nu HTML Checker (https://validator.w3.org/nu) still does but this has been reported as a bug (Add "a modern practices" mode #811) since 2019 and even though it is not getting a ton of attention, maybe it will be solved at some point.

The current browser support is as follows according to caniuse.com:

https://caniuse.com/loading-lazy-attr

see the latest data here: https://caniuse.com/loading-lazy-attr

I guess you can consider this issue to be a bug with the validator itself and not with your code.