Last active
June 6, 2023 16:25
-
-
Save Lockyy/e448ffb784f4e61f5199 to your computer and use it in GitHub Desktop.
Image Preloading
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
ready = -> | |
preloadImages = (imageFilePathArray) -> | |
images = new Array | |
for filePath, index in imageFilePathArray | |
images[index] = new Image() | |
images[index].src = filePath | |
imageFilePathArray = [ | |
'/assets/images/image-one.svg', | |
'/assets/images/image-two.svg' | |
] | |
preloadImages(imageFilePathArray) | |
$(document).ready(ready) | |
$(document).on('page:load', ready) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment