docs/dist/responsive-lazyload.es.js
function initialize(_ref) {
  var _ref$containerClass = _ref.containerClass,
      containerClass = _ref$containerClass === undefined ? 'js--lazyload' : _ref$containerClass,
      _ref$loadingClass = _ref.loadingClass,
      loadingClass = _ref$loadingClass === undefined ? 'js--lazyload--loading' : _ref$loadingClass,
      _ref$callback = _ref.callback,
      callback = _ref$callback === undefined ? function (e) {
    return e;
  } : _ref$callback;

  // Find all the containers and add the loading class.
  var containers = document.getElementsByClassName(containerClass);

  [].forEach.call(containers, function (container) {
    container.classList.add(loadingClass);
  });

  // If we get here, `srcset` is supported and we can start processing things.
  var images = [].map.call(containers, findImageElement);

  // Create a custom event to trigger the event load.
  var lazyLoadEvent = new Event('lazyload-init');

  // Attach an onload handler to each image.
  images.forEach(function (image) {
    /*
     * Once the image is loaded, we want to remove the loading class so any
     * loading animations or other effects can be disabled.
     */
    image.addEventListener('load', function (event) {
      removeLoadingClass(event.target, loadingClass);
      callback(event);
    });

    /*
     * Set up a listener for the custom event that triggers the image load
     * handler (which loads the image).
     */
    image.addEventListener('lazyload-init', loadImage);

    /*
     * Check if the image is already in the viewport. If so, load it.
     */
    maybeTriggerImageLoad(image, lazyLoadEvent);
  });

  var loadVisibleImages = checkForImagesToLazyLoad.bind(null, lazyLoadEvent, images);

  /*
   * Add an event listener when the page is scrolled. To avoid bogging down the
   * page, we throttle this call to only run every 100ms.
   */
  var scrollHandler = throttle(loadVisibleImages, 100);
  window.addEventListener('scroll', scrollHandler);

  // Return a function to allow manual checks for images to lazy load.
  return loadVisibleImages;
}
function initialize(_ref) {
  var _ref$containerClass = _ref.containerClass,
      containerClass = _ref$containerClass === undefined ? 'js--lazyload' : _ref$containerClass,
      _ref$loadingClass = _ref.loadingClass,
      loadingClass = _ref$loadingClass === undefined ? 'js--lazyload--loading' : _ref$loadingClass,
      _ref$callback = _ref.callback,
      callback = _ref$callback === undefined ? function (e) {
    return e;
  } : _ref$callback;

  // Find all the containers and add the loading class.
  var containers = document.getElementsByClassName(containerClass);

  [].forEach.call(containers, function (container) {
    container.classList.add(loadingClass);
  });

  // If we get here, `srcset` is supported and we can start processing things.
  var images = [].map.call(containers, findImageElement);

  // Create a custom event to trigger the event load.
  var lazyLoadEvent = new Event('lazyload-init');

  // Attach an onload handler to each image.
  images.forEach(function (image) {
    /*
     * Once the image is loaded, we want to remove the loading class so any
     * loading animations or other effects can be disabled.
     */
    image.addEventListener('load', function (event) {
      removeLoadingClass(event.target, loadingClass);
      callback(event);
    });

    /*
     * Set up a listener for the custom event that triggers the image load
     * handler (which loads the image).
     */
    image.addEventListener('lazyload-init', loadImage);

    /*
     * Check if the image is already in the viewport. If so, load it.
     */
    maybeTriggerImageLoad(image, lazyLoadEvent);
  });

  var loadVisibleImages = checkForImagesToLazyLoad.bind(null, lazyLoadEvent, images);

  /*
   * Add an event listener when the page is scrolled. To avoid bogging down the
   * page, we throttle this call to only run every 100ms.
   */
  var scrollHandler = throttle(loadVisibleImages, 100);
  window.addEventListener('scroll', scrollHandler);

  // Return a function to allow manual checks for images to lazy load.
  return loadVisibleImages;
}
function initialize ( _ref ) { var _ref$containerClass = _ref . containerClass , containerClass = _ref$containerClass === undefined ? 'js--lazyload' : _ref$containerClass , _ref$loadingClass = _ref . loadingClass , loadingClass = _ref$loadingClass === undefined ? 'js--lazyload--loading' : _ref$loadingClass , _ref$callback = _ref . callback , callback = _ref$callback === undefined ? function ( e ) { return e ; } : _ref$callback ; // Find all the containers and add the loading class. var containers = document . getElementsByClassName ( containerClass ) ; [ ] . forEach . call ( containers , function ( container ) { container . classList . add ( loadingClass ) ; } ) ; // If we get here, `srcset` is supported and we can start processing things. var images = [ ] . map . call ( containers , findImageElement ) ; // Create a custom event to trigger the event load. var lazyLoadEvent = new Event ( 'lazyload-init' ) ; // Attach an onload handler to each image. images . forEach ( function ( image ) { /*
     * Once the image is loaded, we want to remove the loading class so any
     * loading animations or other effects can be disabled.
     */ image . addEventListener ( 'load' , function ( event ) { removeLoadingClass ( event . target , loadingClass ) ; callback ( event ) ; } ) ; /*
     * Set up a listener for the custom event that triggers the image load
     * handler (which loads the image).
     */ image . addEventListener ( 'lazyload-init' , loadImage ) ; /*
     * Check if the image is already in the viewport. If so, load it.
     */ maybeTriggerImageLoad ( image , lazyLoadEvent ) ; } ) ; var loadVisibleImages = checkForImagesToLazyLoad . bind ( null , lazyLoadEvent , images ) ; /*
   * Add an event listener when the page is scrolled. To avoid bogging down the
   * page, we throttle this call to only run every 100ms.
   */ var scrollHandler = throttle ( loadVisibleImages , 100 ) ; window . addEventListener ( 'scroll' , scrollHandler ) ; // Return a function to allow manual checks for images to lazy load. return loadVisibleImages ; }
Initializes the lazyloader and adds the relevant classes and handlers.
@param  {String}   options.containerClass the lazyloaded image wrapper
@param  {String}   options.loadingClass   the class that signifies loading
@param  {Function} options.callback       a function to fire on image load
@return {Function}                        a function to load visible images
Initializes the lazyloader and adds the relevant classes and handlers .