Skip to content

Instantly share code, notes, and snippets.

@cecilemuller
Created June 5, 2024 01:34
Show Gist options
  • Save cecilemuller/f6841c271907521af88451aa96c44103 to your computer and use it in GitHub Desktop.
Save cecilemuller/f6841c271907521af88451aa96c44103 to your computer and use it in GitHub Desktop.
Async image complete
function imageComplete(img) {
return new Promise((resolve) => {
if (img.complete) {
resolve();
} else {
img.onerror = img.onload = () => { resolve() };
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment