lazySizes is working fine. However, you need to change your markup to something similar.
<img data-src="better_me.jpg" data-srcset="better_me2.jpg 400w, better_me.jpg 200w" class="avatar photo avatar-200 lazyload" data-sizes="auto" alt="better_me" width="200" height="200" />
Note srcset changed to data-srcset , and data-lazy changed to data-src . In addition, you must add the lazyload class.
Your sizes attribute doesn't make much sense. Maybe you want to use x descriptors instead? Or just use sizes="200px" ? I dont know. I just switched it to data-sizes="auto" , so it is automatically calculated for you. (But in this case, the image size must be computable before loading the image.)
lazySizes really loads the images before they receive. This is a big improvement for users. A user who scrolls something in mind does not want to wait. Lazyloader, which starts loading the image after it is already in view, disrupts the user.
One nice thing about lazySizes is that this lazy bootloader checks to see if the browser is currently loading and resolving this fact, whether it only downloads as images or preloads images at close range.
But if you do not want this, you can control this by setting the lazySizes expand and expFactor .
alexander farkas
source share