Hi! My name is {profile_name}

I\'m playing with the canvas element in HTML5 and I have noticed a peculiar behavior. On initial load, an image I\'m displaying does not show. However, when I refresh the b
Actually, even just using image.onload = function() {}
, you can still run into problems. Do use this technique (that's not at all what I'm saying), but move it to the bottom of your page.
As an example, I have a social networking site that uses canvas to show the profile photo (URI stored to the DB), and print it to canvas, then overlay a logo.
Hi! My name is {profile_name}
Add {profile_name} as a friend?
Click to visit {profile_name} Gallery
...
Ideally, this would go all the way at the bottom before the end
tag, but I put it up higher because of my template system. Apparently, this gives the image time to load after the canvas element has been drawn to the screen and is ready to receive input.
I can't rely on setting the background of the canvas, and I have no desire to contend with refreshes. For whatever reason, just including the script with img.onload = function() {}
was not enough. Move it lower, and save yourself the headaches.