1$.fn.lazyLoad = function(margin) { 2 var _self = this; 3 var elements = []; 4 5 _self.each(function () { 6 if ($(this).data('src')) { 7 elements.push(this); 8 } 9 }); 10 11 var lazyLoader = function () { 12 var windowHeight = $(window).height(); 13 var windowScrollTop = $(window).scrollTop(); 14 var i = 0; 15 16 while (i < elements.length) { 17 var element = $(elements[i]); 18 var offset = element.offset(); 19 var height = element.outerHeight(true); 20 21 if (element.is(':hidden') && offset.top === 0 && offset.left === 0) { 22 i++; 23 continue; 24 } 25 26 if (offset.top - margin <= windowHeight + windowScrollTop && 27 offset.top + height + margin >= windowScrollTop 28 ) { 29 element.attr('src', element.data('src')); 30 element.removeData( "src" ); 31 elements.splice(i, 1); 32 } else { 33 i++; 34 } 35 } 36 }; 37 38 $(window).on('scroll', lazyLoader); 39 $(window).on('resize', lazyLoader); 40 lazyLoader(); 41 42 return _self; 43};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.