Is `complete` a boolean? Maybe check the type explicity? `if (img.complete !== true)`