Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Preload images on page
preloadImages() {
let i = 0;
const arr = [...Backgrounds, ...Images];
return new Promise(resolve => {
arr.map(filename => {
const img = new Image();
img.src = filename;
img.onload = () => (++i == arr.length) ? resolve() : 1;
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.