Warning Binding the lazyload_event to 'scroll' may cause excessive lag.

  • This widget, added in v2.24.0, integrates the popular jQuery lazyload plugin & jQuery scrollstop.
  • This widget will only work if:
    • The image class, set by the lazyload_imageClass option is included.
    • The image width & height attributes are set.
    • The url to the image is added to the data-attribute, set by the lazyload_data_attribute option, and not the image src attribute.
    <img class="lazy" data-original="images/logo.png" width="300" height="300">
  • The images will load only if:
    • The image is inside the viewport.
    • When the user has stoped scrolling; this is because the lazyload_event option is set by default to use the "scrollstop" event, which is added by the jQuery scrollstop plugin (see lazyload_event option for more details).
  • In this demo, scroll down the page to see the lazyload plugin in action.
  • This widget will not work with the original tablesorter plugin (v2.0.5).

Demo

First Name
Last Name
Image
BillMurrayMurray
JoyceYoungRed
JohnHoodGrey
ClarkKentBear
BeverlyPyleBlue
BruceAlmightyRandom
BillyMurrayMurray
FrankBedlamBlue
HarrySallyBear

Javascript

$(function() {
$("table").tablesorter({
theme : 'blue',
widgets : [ 'lazyload', 'filter', 'zebra' ],
widgetOptions : {
// widget options
lazyload_imageClass : 'lazy',
// scrollStop option (https://github.com/ssorallen/jquery-scrollstop)
lazyload_latency : 250,
// lazyload options (see http://www.appelsiini.net/projects/lazyload)
lazyload_threshold : 0,
lazyload_failure_limit : 0,
lazyload_event : 'scrollstop',
lazyload_effect : 'show',
lazyload_container : window,
lazyload_data_attribute : 'original',
lazyload_skip_invisible : true,
lazyload_appear : function( elements_left, settings ) {
// callback fired when image is in view, but before it is loaded
$(this).addClass( 'tablesorter-processing' );
},
lazyload_load : function( elements_left, settings ) {
// callback fired after image has loaded
$(this).removeClass( 'tablesorter-processing' );
},
lazyload_placeholder : 'data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=='
}
});
});

HTML

<table class="tablesorter">
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Image</th>
</tr>
</thead>
<tbody>
<tr><td>Bill</td><td>Murray</td><td><img class="lazy" data-original="http://www.fillmurray.com/300/500" width="300" height="500" alt="Murray"></td></tr>
<tr><td>Joyce</td><td>Young</td><td><img class="lazy" data-original="http://placehold.it/300x500/ff0000/ffffff" width="300" height="500" alt="Red"></td></tr>
<tr><td>John</td><td>Hood</td><td><img class="lazy" data-original="http://placehold.it/300x500" width="300" height="500" alt="Grey"></td></tr>
<tr><td>Clark</td><td>Kent</td><td><img class="lazy" data-original="http://placebear.com/300/500" width="300" height="500" alt="Bear"></td></tr>
<tr><td>Beverly</td><td>Pyle</td><td><img class="lazy" data-original="http://placehold.it/300x500/ff00ff/ffffff" width="300" height="500" alt="Blue"></td></tr>
<tr><td>Bruce</td><td>Almighty</td><td><img class="lazy" data-original="http://lorempixel.com/300/500" width="300" height="500" alt="Random"></td></tr>
<tr><td>Billy</td><td>Murray</td><td><img class="lazy" data-original="http://www.fillmurray.com/300/500" width="300" height="500" alt="Murray"></td></tr>
<tr><td>Frank</td><td>Bedlam</td><td><img class="lazy" data-original="http://placehold.it/300x500/0000ff/ffffff" width="300" height="500" alt="Blue"></td></tr>
<tr><td>Harry</td><td>Sally</td><td><img class="lazy" data-original="http://placebear.com/300/500" width="300" height="500" alt="Bear"></td></tr>
</tbody>
</table>