Created
September 18, 2015 10:10
-
-
Save Viroide/80052bb057f695ee7dd4 to your computer and use it in GitHub Desktop.
To preload a number of backgrounds that are named like "background-*.png"
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
| $.preloadImages = function(cantidad) { | |
| for (var i = 0; i < cantidad; i++) { | |
| $("<img />").attr("src", "/path/background-"+i+".png"); | |
| } | |
| } | |
| $.preloadImages(10); //number of backgrounds |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Inspired /copied from https://css-tricks.com/snippets/jquery/image-preloader/