Lazysizes: Get rid of lazyload class

Created on 8 Mar 2017  路  2Comments  路  Source: aFarkas/lazysizes

Hello,

Love this plugin, however I'm not fan of adding a class on each imagess to apply laryload on them.

It could be done by targeting image with data-src or data-srcset attributes directly.

Most helpful comment

My two cents on this:

  1. class-based selectors outperforms data attribute matching,
  2. lazyload class name can be reconfigured via JS API options to e.g. "lazy" or "lz" and so on if the size of html code matters, or if it's easier to be used everytime,
  3. I like to style my lazy loaded images, mostly to add opacity transition effects.

So I find it beneficial the way it is now.

All 2 comments

My two cents on this:

  1. class-based selectors outperforms data attribute matching,
  2. lazyload class name can be reconfigured via JS API options to e.g. "lazy" or "lz" and so on if the size of html code matters, or if it's easier to be used everytime,
  3. I like to style my lazy loaded images, mostly to add opacity transition effects.

So I find it beneficial the way it is now.

It could be done by targeting image with data-src or data-srcset attributes directly.

Yeah, but what about scripts, iframes? That kind of stuff adds code complexity and starts to make assumptions about data structure that could have unexpected consequences. For example, WordPress may add data-src AND src automatically. But it doesn't add the lazyload class.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zenderol picture zenderol  路  5Comments

jamiemagique picture jamiemagique  路  7Comments

maximelebreton picture maximelebreton  路  4Comments

ClemensSchneider picture ClemensSchneider  路  7Comments

Freekbron picture Freekbron  路  3Comments