Skip to content

Instantly share code, notes, and snippets.

@Lockyy
Last active June 6, 2023 16:25
Show Gist options
  • Save Lockyy/e448ffb784f4e61f5199 to your computer and use it in GitHub Desktop.
Save Lockyy/e448ffb784f4e61f5199 to your computer and use it in GitHub Desktop.
Image Preloading
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