$(window).bind("scroll", listen) var scrollTop = function() { return $(window).scrollTop() }; var fix = -100; var listen = function() { var _scrollTop = scrollTop(); if (_scrollTop - fix > 50) { fix = _scrollTop; load() } }; var height = function() { return $(window).height() + scrollTop() + 50 }; var loadImg = $("img[src2]"); var load = function() { loadImg.each(function(j) { if ($(this).offset().top <= height()) { var src = $(this).attr(i); if (src) { $(this).attr("src", src).removeAttr(i).show() } } }) };