Facebook Like Image Preloader

Supplemental 251 views
0
0 Flares 0 Flares ×

Ever noticed how fast images load when paging through a Facebook photo album? This is because Facebook is preloading each of these images into your browser’s cache before you even view them. Here’s how you can achieve a similar behavior on your website using some jQuery magic.

var nextimage = "/images/some-image.jpg";
$(document).ready(function(){
window.setTimeout(function(){
var img = $("<img>").attr("src", nextimage).load(function(){
//all done
});
}, 100);
});

For Reference:

Emulate Facebook By Preloading Previous & Next Photo Gallery Images

Provided by: Cats who Code
Tagged with: ,
Posted in jQuery

Discuss:

One comment on “Facebook Like Image Preloader
  1. Sam says:

    Would be interesting to see a live demo of snippet in action and maybe a little more detail on how to use it?

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

No Trackbacks.

Login

Register | Lost your password?
0 Flares Twitter 0 Facebook 0 Google+ 0 0 Flares ×