[javascript] Detect when an image fails to load in Javascript