P.when(“jQuery”, “jquery-lazyload”, “ready”).execute(function($) {

"use strict";

function filterByClassName(collection, className) {
  if(!isArrayAndNotEmpty(collection)) {
    return false;
  }
  return (
    collection.filter(function(i) {
      return !$(collection[i]).hasClass(className);
    })
  );
}

function isArrayAndNotEmpty(arr) {
  return (
    typeof arr !== "undefined" && arr !== null && arr.length > 0
  );
}

function initLazyLoad(imgs) {
  var $winWidth = $(window).width();
  $winWidth > 992 ? attachLazyLoad(filterByClassName(imgs.lazyImgs, "u-lazy-load--attached")) : attachLazyLoad(filterByClassName(imgs.lazyImgsMobile, "u-lazy-load--attached"));
}

function attachLazyLoad(els) {
  if(!isArrayAndNotEmpty(els)) {
    return;
  }

  $(els).lazyload({
    threshold: 400,
    effect: "fadeIn",
    effectspeed: 100,
  }).addClass("u-lazy-load--attached");
}

var imgs = {};
imgs.lazyImgs = $(".u-lazy-load");
imgs.lazyImgsMobile = filterByClassName(imgs.lazyImgs, "u-lazy-load--noMobile");

$(window).resize(function() {
  initLazyLoad(imgs);
})

initLazyLoad(imgs);

});