After installing this module I get an error sometimes: Images won't load and the next error will show on console: Uncaught TypeError: $(...).lazy is not a function With a link to this section of code in the scripts.phtml
require(['jquery', 'lazyLoad', 'lazyLoadPlugins'], function($) {
window.mgzLazyload = function(config) {
var settings = {
bind: "event",
delay: <?= $delay ? $delay : '-1' ?>,
threshold: <?= $threshold ?>,
effect: "<?= $effect ?>",
effectTime: <?= $effectTime ?>,
afterLoad: function(element) {
$(element).removeClass('lazy-loading').removeClass('lazy-blur').addClass('lazy-loaded');
}
};
if (config) settings = $.extend(settings, config);
$('.lazy').lazy(settings);
}
window.mgzLazyload();
$(document).on('ajaxComplete', function (event, xhr, settings) {
window.mgzLazyload();
});
$(document).ready(function($) {
$('.owl-carousel').on('changed.owl.carousel', function(event) {
window.mgzLazyload();
});
});
I tried to fix it on my own, but can't seem to force the module to load lazy before this section. Here is an example: https://jobbooz.com/hombres/indumentaria/todos-los-modelos.html?sale=1&size=168
NOTE: It's not always, most of the time it will load correctly, so you have to load it a couple of times.