Skip to content

data-srcset remaining as data-srcset when visible #134

@TokyoWeb

Description

@TokyoWeb

Hi ! First i would like to thank you for Lozad. So powerful and such a small size. I love it.

Nonetheless after two months using and placing like 500 responsive images in my site, I just realized I must be doing something wrong or there is an issue when using "data-srcset". The "data-src" is loaded as "src" when visible, but the data-srcset remains always "data-srcset" then the browsers are only loading the image that I place in "data-src" and ignoring all the responsive images inside "data-srcset".

I first realized this when checking a performance test (yellowlab tools reported same weight for mobile and desktop in an image that I thought was below the fold, and then I realized my issue, it should have loaded different images for mobile, tablet and desktop). Then I checked on Safari, Chrome, Firefox and when disabling cache always only one image is shown.

If I load the images as "picture tag", no issue. I did a couple of codepen with my code.

Example using picture tag https://codepen.io/tokyoweb/pen/MPVVbK working as expected.

Example using data-srcset https://codepen.io/tokyoweb/pen/WazZLP which is the code I use in like 500 images in my site :(

No matter what I do, the responsive images inside "data-srcset" remain like that, because I think I must be doing some error and "data-srcset" doesn't change to "srcset" when visible as it does happen with "data-src" that become "src" when visible.

Thanks and I am sure it must be me doing something wrong.

<img class="lozad" data-src="image-w250.jpg" data-srcset="image-w446.jpg 446w, image-w606.jpg 606w, image-w700.jpg 700w" />

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions