Support » Plugin: BJ Lazy Load » Solution: Making BJ Lazy Load More Awesome and Work with Srcset

  • Since it’s near impossible to find a Lazy Load plugin that works with themes or frameworks like Cherry while also working with the provided srcset.

    BJ Lazy Load is almost all-around perfect, you just need to change something in the bj-lazy-load.js and bj-lazy-load.min.js files

    Find this:

    ( null != el.getAttribute(‘data-srcset’) ) {
    el.setAttribute( ‘srcset’, el.getAttribute(‘data-srcset’) );

    and edit it to make it like this:

    ( null != el.getAttribute(‘data-lazy-srcset’) ) {
    el.setAttribute( ‘srcset’, el.getAttribute(‘data-lazy-srcset’) );

    This edit makes this Lazy Load plugin work so much better with newer versions of WordPress.


Viewing 1 replies (of 1 total)
  • Indeed, this plugin claims to support the srcset attribute, but the attributes queried in the js are wrong. The rewriter names the srcset as data-lazy-srcset, but the js is looking for data-srcset, as @casbboy mentioned.
    I discovered this while adding lazy load support for WebP to the EWWW Image Optimizer. With the tweaks mentioned above, it will work perfectly as of EWWW IO 3.1.

Viewing 1 replies (of 1 total)
  • The topic ‘Solution: Making BJ Lazy Load More Awesome and Work with Srcset’ is closed to new replies.