lazy-img | Vaadin

Lazy loading img

[ This description is mirrored from at on 2019-05-10 ]

Published on

Demo and API docs


lazy-img is a lazy loading img element that is shadow-dom friendly and uses IntersectionObserver to detect when images are within the viewport and need to be loaded.

The default behavior is to use the browser viewport but more specific control can be provided by setting the observe property to a parent selector (either an element id, class or tag name):

<div id="myscroller">
        <lazy-img src="image1.jpg" observe="#myscroller"></lazy-img>
        <lazy-img src="image2.jpg" observe="#myscroller"></lazy-img>
        <lazy-img src="image99.jpg" observe="#myscroller"></lazy-img>

margin and threshold allow control over exactly when the loading is triggered as the element comes into view. margin can reduce or extend the detection area of the container and threshold can determine what proportion of the image needs to be within the area.

Demo is based on this example of intersection-observer

If used on a browser without support for IntersectionObserver a polyfill will be loaded automatically from the service.

Configure this with the following code in index.html:

  // Define polyfills for features that our app depends on:
  window.PolyPoly = {
    features: []
  ('IntersectionObserver' in window) || window.PolyPoly.features.push('IntersectionObserver');


Link to this version
ImportedReleased 06 March 2017MIT License
Framework Support
Polymer 1.0+
Browser Independent
Install with
bower install --save CaptainCodeman/lazy-img"#0.0.7"
Run the above Bower command in your project folder. If you have any issues installing, please contact the author.
Release notes - Version 0.0.7


  • polymer#Polymer/polymer#^1.4.0
  • poly-poly#CaptainCodeman/poly-poly#^0.0.4