Created
June 12, 2014 10:33
-
-
Save bencooling/62470207a14d3c6ca0b5 to your computer and use it in GitHub Desktop.
Javascript Lazy Load Images
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- markup --> | |
<img data-src="/image/to/lazy/load.jpg" src="" /> | |
<script type="text/javascript"> | |
lazyLoad : function($images){ | |
$images.each(function(i, el){ | |
var $el = $(el); | |
if (!el.loaded){ | |
$el.attr('src', $el.attr('data-src')); | |
el.loaded=1; | |
} | |
}); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment