Created
March 28, 2019 10:44
-
-
Save pawelmysior/6358a58c877cbf1036660b7fb835f013 to your computer and use it in GitHub Desktop.
Images 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
<script> | |
window.addEventListener('load', function () { | |
const imagesToPreload = [ | |
'/images/test.png', | |
// .. | |
]; | |
let images = []; | |
for (let i = 0; i < imagesToPreload.length; i++) { | |
images[i] = new Image(); | |
images[i].src = imagesToPreload[i]; | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment