Created
November 15, 2013 00:19
-
-
Save carlos-sanchez/7476906 to your computer and use it in GitHub Desktop.
Facebook like image preloader. 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.
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
var nextimage = "/images/some-image.jpg"; | |
$(document).ready(function(){ | |
window.setTimeout(function(){ | |
var img = $("<img>").attr("src", nextimage).load(function(){ | |
//all done | |
}); | |
}, 100); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment