-
-
Save solobat/95b1906e1e8fb989d5fd1057b29eafba to your computer and use it in GitHub Desktop.
Easy jquery/zepto images preload
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
| var images = ["path/to/image", "path/to/image", ... , "path/to/image"], | |
| preloaded = images.length; | |
| _.each(images, function(img) { | |
| var image = $('<img />').attr('src', img); | |
| image.on('load', function(){ | |
| preloaded--; | |
| if (preloaded === 0){ | |
| console.log("All preloaded!"); | |
| } | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment