Closed alpual closed 10 months ago
Do you have any suggestions for the HTML code and the attributes?
This CodePen is using intersection observers. With a polyfill, that might work across browsers. I know jQuery Lazy also handles background images, but their javascript disabled solution is inferior to yours, in my opinion. Yours is more DRY, not requiring the noscript tags Plus, I don't know how their solution handles srcset, whereas yours clearly does.
Background images support is added in v3.0 🎉
I know that this is designed to solve issues using srcset, which isn't supported for background images, but it is hard to justify pulling in two dependencies, one for responsive img tags, and another for background images. Is there some kind of way to adapt this for background images, or provide support for that using another technique?