I was told it is necessary to set the onload function before setting src for an image object. I\'ve searched in SO for this.
onload
src
I found this c
The browser will start downloading the image asychronously as soon as you assign a src, so there is the possibility the download could complete before you attach the onload event handler and never fire the code to add the image to the DOM.