You could check the complete property on the image before applying the onload event.
if (!img.complete) {
// add onload listener here
}
You could check the complete property on the image before applying the onload event.
if (!img.complete) {
// add onload listener here
}