The first is the best to date.
The first one benefits from efficiency (slightly) because the second and third forces the page to re-plan unnecessarily. Also, if there is a bug in JavaScript that stops subsequent execution, the page will look terribly weird.
In addition, you should always choose the first for accessibility purposes. If someone has JavaScript disabled, you still want them to see the fallback content. Even if you need to say "enable JavaScript!". or "Get a modern browser!"
If you use the second or third method, the user may never know, and they will continue to think simply that you are sucking page layouts, because there is a strange space where there should be spare content (or canvas, for that matter).
Even with all this, methods 2 and 3 are a little out of order. When do you add canvas? after onload fires? Well, by shooting onload , the page just said that the DOM was made to dance and you're done! And then you go and change the DOM!
... How rough!
Of course, you probably won't use any libraries that rely on the implicit promise made in onload that you understand using 2 or 3, but this is an unnecessary break in the agreement if you can avoid it.
By the way, to run simple applications or examples, I have this script:
http://jsfiddle.net/eAVMs/
The first method is used. If you use canvas a lot, you should also add this script!
source share