publiclab / plots2

a collaborative knowledge-exchange platform in Rails; we welcome first-time contributors! :balloon:
https://publiclab.org
GNU General Public License v3.0
961 stars 1.83k forks source link

lazyload scope #8098

Open jywarren opened 4 years ago

jywarren commented 4 years ago

@Tlazypanda i wonder if this line is running lazyload on all images across the entire page, and if that's a problem. Do we need to limit CSS scope to only img on this page?

Or alternatively, is this covered by a similar universal img statement elsewhere?

https://github.com/publiclab/plots2/blob/c60aaabb56c018962c76abf3f5f2d114f8492d15/app/views/notes/_card.html.erb#L72

Tlazypanda commented 4 years ago

Hey @jywarren assuming that we are going to lazyload all images I had added the config for all image_tag to be lazyloaded here - https://github.com/publiclab/plots2/blob/badf58e8b75e4eb1d07d524464178f8eaeacb250/config/initializers/lazyload.rb#L8

We can migrate to adding a lazy:true to the images and $("img.lazy").lazyload(); we want to be lazyloaded and eliminating this above setting.

Right now checked out the main website so I think for all the places where this script is included if on that page there are img tags then they are lazyloaded but on image_tag helpers they are lazyloaded using the placeholders(grey default thing).

For now I have added this script mostly where we are using dynamic images hence it's better to keep this script in different files rather than a single universal place.