I am unable to lazy-load webp images because the class attribute is not seen by browser.
I am running the audit in Chrome browser to speed up my site as much as possible and the next thing to be done is to make images off the screen to be lazy-loaded. For this purpose I need to add to all these images some class that I will call in JavaScript. But where should I put the class attribute? If I put it in the place as in the code below the attribute is not seen. Also some free online SEO audits claim, that there is a lack of alt attribute (when I run them from Chrome).
<picture>
<source srcset="images/img1.webp" type="image/webp">
<source srcset="images/img1.jpg" type="image/jpg">
<img data-src="images/img1.jpg" class="blog-img js-lazy-image" alt="some alt text">
</picture>
I also tried to put the alt and class attributes within the source tag, but it doesn't work as well. So what is the way to add these attributes properly?
If I put just:
<img data-src="images/img1.jpg" class="blog-img js-lazy-image" alt="some alt text">
lazy loading works fine. But I would like to use it with picture...source tags.
Thank you in advance for any replies.