Skip to content

Instantly share code, notes, and snippets.

@JonMidhir
Last active December 20, 2015 20:09
Show Gist options
  • Save JonMidhir/6188842 to your computer and use it in GitHub Desktop.
Save JonMidhir/6188842 to your computer and use it in GitHub Desktop.
Here's a handy little plugin for jQuery to preload images on a webpage. Planning to use it on midhirrecords.com
$ = jQuery
// Takes an array of strings
$.preloadImages = function(images) {
$(images).each(function() {
$('<img />')[0].src = this;
});
}
// Use it anytime after the document loads
$(document).ready(function() {
$.preloadImages(['images/lolcat.jpg', 'images/awesome.jpg', 'images/logo.jpg']);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment