The simplest way to load images
jQuery Lazy is a compact jQuery Lazy Image plugin (1.27kb minified) that differentiates from the above scripts in a few ways. Most notable about this script is the ability to lazy load images in both a vertical and horizontal layout, which is useful if you have a scrollable horizontal “carousel of images”, for example. Also, the plugin comes with additional, optional plugins (another 2.27kb in size total) you can add on to lazy load other types of content, such as IFRAME content, JavaScripts, AUDIO and VIDEOS. And finally, there are CDN hosted versions of the plugins available so you don’t have to upload any files to your server
This file contains 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
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> | |
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery.lazy/1.7.4/jquery.lazy.min.js"></script> | |
<img class="lazy" src="img/blank.gif" alt="Photo" data-src="http://pipsum.com/800x500.jpg"> | |
<img class="lazy" src="img/blank.gif" alt="Photo" data-src="http://pipsum.com/400x500.jpg"> | |
<img class="lazy" src="img/blank.gif" alt="Photo" data-src="http://pipsum.com/700x500.jpg"> | |
<script> | |
$(function() { | |
$('.lazy').lazy(); | |
}); | |
</script> |
More ways is here http://blog.dynamicdrive.com
Comments
Post a Comment