Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- document.getElementById vs document.write?


lucy24 - 11:48 am on Nov 12, 2012 (gmt 0)


It's less about "how long" than about "when". document.write has to be done before the page finishes loading. (This is one of those mistakes nobody makes more than once ;)) innerHTML can be popped in at any time.

Crude analogy: think of a page filled with images that either have or don't have "height" and "width" statements. If they're missing, the browser has to load up everything before it can figure out where things go, and has to keep redrawing the page. If the height and width are in the HTML, the browser can shove in placeholder boxes and slowly fill them in while you're reading the page.

But if nothing else can happen until the images show up-- still in analogy here-- then it doesn't really matter.

This is assuming you're talking about explicit visible text. If you're changing styles or any other behind-the-scenes action, there are other ways to do it.

And the biggest assumption of all: Does it have to be javascript? That is: Is the text based on information about the user-- and in particular is it based on information that won't come through in an ordinary User-Agent string (which is visible to the server before the page even starts to load)?


Thread source:: http://www.webmasterworld.com/javascript/4518258.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com