Created
February 22, 2013 17:28
-
-
Save dongerardor/5015151 to your computer and use it in GitHub Desktop.
Preload images. Providing an array of path to images, we create image objects which preloads them.
This file contains hidden or 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
| (function($) { | |
| var cache = []; | |
| // Arguments are image paths relative to the current page. | |
| $.preLoadImages = function() { | |
| var args_len = arguments.length; | |
| for (var i = args_len; i--;) { | |
| var cacheImage = document.createElement('img'); | |
| cacheImage.src = arguments[i]; | |
| cache.push(cacheImage); | |
| } | |
| } | |
| })(jQuery); | |
| jQuery.preLoadImages( | |
| "http://s3.amazonaws.com/cdn.infografiaepoca.com.br/770quizOscarCartazes/images/Amor_det.jpg", | |
| "http://s3.amazonaws.com/cdn.infografiaepoca.com.br/770quizOscarCartazes/images/Amor.jpg", | |
| "....", | |
| "http://s3.amazonaws.com/cdn.infografiaepoca.com.br/770quizOscarCartazes/images/AsAventurasDePi.jpg" | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment