Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
images = [
_preload = (src)->
new Promise (resolve, reject)->
image = document.createElement 'img'
image.src = src
image.onload = -> resolve image = 'none'
document.body.appendChild image
setTimeout reject, 30000
render = (images)->
# show something using all images
preload = (images)->
Promise.all (_preload src for src in images)
preload(images).then render
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment