Last active
December 20, 2015 20:09
-
-
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
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
$ = 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