Jail bug
by Vladimir
HTML
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<img class="lazy" data-href="http://placekitten.com/200/300" src="http://placekitten.com/50/50" />
<img class="lazy" data-href="http://placekitten.com/300/300" src="http://placekitten.com/50/50" />
<img class="lazy" data-href="http://placekitten.com/400/300" src="http://placekitten.com/50/50" />
<img class="lazy" data-href="http://placekitten.com/500/300" src="http://placekitten.com/50/50" />
<img class="lazy" data-href="http://placekitten.com/600/300" src="http://placekitten.com/50/50" />
CSS
img {
width:200px;
height: 300px;
display: block;
}
JavaScript
$(function(){
$('img.lazy').asynchImageLoader();
});
/*!
* JqueryAsynchImageLoader (JAIL) : plugin for jQuery
*
* Developed by
* Sebastiano Armeli-Battana (@sebarmeli) - http://www.sebastianoarmelibattana.com
* Dual licensed under the MIT or GPL Version 3 licenses.
*/
/*
Copyright (c) 2011 Sebastiano Armeli-Battana (http://www.sebastianoarmelibattana.com)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
/* JAIL helps loading images asynchronously and it can be used to make your page load faster.
* Selected images will be downloaded after the document is ready not blocking the page
* to render other elements. Images can be loaded after an event is triggered (like clicking
* on a link, mouseovering on some elements, scrolling up/down) or after some delay or simply the
* visible images will be loaded.
*
* First of all, this plugin requires you to make some HTML changes.
* E.g.
* <img class="lazy" src="/img/blank.gif" data-href="/img/image1.jpg" width="x" height="y"/>
*
* You can define a noscript block in order to respect the principles of progressive
* enhancemnt
* E.g.
* <noscript>
* <img class="lazy" src="/img/image1.jpg" width="x" height="y" />
* </noscript>
*
* You can call the function in this way
* E.g.
* $(function(){
* $('img.lazy').asynchImageLoader();
* });
*
* You can also have different configurations:
*
* - timeout : number of msec after that the images will be loaded - Default: 10ms
* - effect : any jQuery effect that makes the images display (e.g. "fadeIn"). If you are loading a large number of images, it...