Skip to content

Instantly share code, notes, and snippets.

@pawelmysior
Created March 28, 2019 10:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pawelmysior/6358a58c877cbf1036660b7fb835f013 to your computer and use it in GitHub Desktop.
Save pawelmysior/6358a58c877cbf1036660b7fb835f013 to your computer and use it in GitHub Desktop.
Images preloading
<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