Skip to content

Releases: pagespeed-pro/lazy

1.3.0

06 Mar 09:36
Compare
Choose a tag to compare

Updated and improved.

  • Added: z shortcut selector for [data-z] attribute.

1.2.3

21 Nov 17:43
Compare
Choose a tag to compare
  • Added: fallback image option in compressed srcset
  • Bugfix: inview callback not working when using background-image module.
  • Bugfix: compressed srcset not applied.
<!-- compressed srcset -->
<img data-z='['path/img.jpg', [412, 800, 1280, 1600, 1920], '/base/path/', 'fallback-image.svg']'>

1.2.2

06 Nov 21:06
Compare
Choose a tag to compare
  • Bugfix: click extension throws exception on events when using client-side .webp rewrite.
  • Bugfix: polyfill src string passed to old $async.js() (now $async() for both CSS and js).

For data-attr extension:

  • added data-b global base path for lazy-loaded images.
  • added data-zz multi config param (accepts JSON array with configurations)
  • removed: || token based multi-config

data-zz multi config and data-b (base)

<script async src="/js/z.js" data-zz='["z","zb",{
    selector: '[data-src]'
}]' data-b="/base-path/"></script>

<img data-z="relative/path.jpg">
<!-- src: /base-path/relative/path.jpg -->

1.2.1

26 Sep 19:36
Compare
Choose a tag to compare
  • Added: responsive lazy-loaded background module.
  • Added: shortcuts: z = [data-z], zb = [data-zb] for background images.
$lazy('z'); // default config

1.2.0

04 Jun 13:52
Compare
Choose a tag to compare
  • data-l HTML attribute for configuration renamed to data-z
<script async src="dist/lazy+data-attr.js" data-z='{
   "selector": "[data-src]", 
   "observer": { 
      "threshold": [1.0],
      "trackVisibility": true,
      "delay": 100
   }
}'></script>

1.1.6

01 Jun 08:33
Compare
Choose a tag to compare

Added: option to force inview event on element using 1 as inview handler: $lazy("[selector]", 1);
Added: z event name to enable manually triggering of inview event on elements. (when using click extension)

// load all images before printing
window.onbeforeprint = function() {

	// get all applicable elements by using an empty inview handler
	var images = $lazy('[data-z]', function() {});

	// fire `z` event on images
	if (images) {
		images.forEach(function(i) {
			try {
		        var EventName = 'z';
		        if( i.fireEvent ) {
		            i.fireEvent( 'on' + EventName );     
		        } else {   
		            var evObj = document.createEvent( 'Events' );
		            evObj.initEvent( EventName, true, false );
		            i.dispatchEvent( evObj );
		        }
		    } catch (e) {

		    }
		});
	}
};

1.1.5

19 Feb 07:14
Compare
Choose a tag to compare
  • Support for iPhone 5 / old browsers.

1.1.4

12 Feb 17:20
Compare
Choose a tag to compare
  • data-src and data-srcset attributes removed by default inview callback for lazy loading images to allow placeholder CSS based on the img[data-src] selector.
img[data-src] {
    background-image: url(placeholder.svg);
    background-size: cover;
    background-position: 50% 50%;
    background-repeat: no-repeat;
    background-color: #f9f9f9;
    cursor: context-menu;
}

img[data-src]:hover {
    background-color:#efefef;
}

Result:

Screenshot from 2020-02-12 17:26:22

1.1.3

12 Feb 16:28
Compare
Choose a tag to compare
  • Added: event handler based fallback (click, mouseover etc.)

Optional config:

{"events": ["click"]}

Also available as compressed array index 4.

The event handler based fallback enables to trigger the observer callback using an event handler when the observer fails.

This feature enables to show a user friendly placeholder using CSS and SVG.

img[data-src] {
    background-image: url(placeholder.svg);
    background-size: cover;
    background-position: 50% 50%;
    background-repeat: no-repeat;
    background-color: #f9f9f9;
    cursor: context-menu;
}

img[data-src]:hover {
    background-color:#efefef;
}

Result:

Screenshot from 2020-02-12 17:26:22

1.1.2

12 Feb 14:46
Compare
Choose a tag to compare
  • Polyfill queue now returns DOM elements.