hongaar / unveil2

:mount_fuji: A very lightweight jQuery plugin to lazy load images
http://nabble.github.io/unveil2
38 stars 11 forks source link

Add srcset support #12

Open BeatLaG opened 8 years ago

BeatLaG commented 8 years ago

Since Wordpress implements this feature natively, it would be awesome seeing the plugin to handle images sets :)

hongaar commented 8 years ago

Thanks, good suggestion!

hongaar commented 8 years ago

@BeatLaG Do you know how WordPress handles IE? Do they use a polyfill or do they just degrade the experience on IE?

BeatLaG commented 8 years ago

Looks like they are using a polyfill to handle old browsers based in -> https://scottjehl.github.io/picturefill/ adding in this way an extra dependency :(

hongaar commented 8 years ago

Yeah that's too bad, but I think in the end it would still be cleaner to use srcset as opposed to the current situation: viewport width calculations and using a rather verbose syntax.

hongaar commented 8 years ago

Currently, around 65% of browsers used (globally, 75% in USA) support the srcset attribute (caniuse).

Picturefill looks really nice, but its minified source is 11.5 KB (compared to currently 2 KB for unveil2).

Maybe we should just include instructions on how to include picturefill and leave the choice of using it up to users? Upside is modularity, downside is extra complexity (which will will fade away over time as browser support increases).

BeatLaG commented 8 years ago

I totally agree, Joram. Let the user choose would cover any scenario. In the worst case when not implementing a polyfill the markup would be only working for the main src attribute and not affecting to the other pictures set, this would result in non broken layouts in any case. The only point would be that unveil would not work for those pictures in the set.

To me it sounds perfect, much better that bloating the plugin and doing it heavy.