Skip to Content


Public news / October 2006 / innerHTML Replacemnt

innerHTML Replacemnt

Two javascript functions that manipulate the DOM, and together provide the same benefits as innerHTML whilst adhering to web standards.

Hopefully will help reduce a few DOM scripting headaches :)

permanent link 15 oct at 17:48 by Steve Tucker

There are 3 guest comments so far.

commentat 18:36 on 15 October 2006, Craig James wrote:

Nice pick Steve. Very useful! Thanks for posting.

commentat 13:16 on 16 October 2006, Aaron Bassett wrote:

Performance wise how does this compare to using the normal innerHTML?

I remember doing some speed checks on DOM methods vs innerHTML a while ago and the DOM methods performed very badly compared to innerHTML

I know that the DOM methods are web standards and innerHTML is not but lets be realistic. The innerHTML method isnt going to vanish anytime soon. And sometimes a huge increase in performance can be worth bending the rules (standards) for.

However I would prefer to use DOM methods so if you can provide some performance figures in comparission to innerHTML that'd be great :)

commentat 13:53 on 16 October 2006, Steve Tucker wrote:

Thanks Craig :)

@Aaron: I know exactly where you're coming from with this comment. Speed is very important, which is why I've been streamlining the function for greater efficiency for some time. Other than basic eyeballing checks however I have done very few tests. To the naked eye innerXHTML appears very quick indeed. If you look at http://www.hasselhoffisgod.com innerXHTML completely rewrites the whole document - everything within the body tag - on page load, and completes without even a blink. I plan however to do some proper stopwatch testing soon, and when I do I will post the results on my website with the rest of the data Ive collected :)

Add a comment:

(required, non-public)

  |  Chars left: 1000

Keep the comment relevant, constructive and be polite.
A valid email address or URL to your site must be provided, or the comment might get deleted. Content seemed inappropriate or offensive may be edited and/or deleted. Avoid explicit language and words such as "sucks" and "ripoff". For more in-depth discussions use our forum. Email addresses are never displayed. Line breaks and paragraphs are automatically converted - no need to use <p> or <br/>. Quotes & apostrophes are automatically converted to smart punctuation. Be careful when copying and pasting portions of entries or other comments. The following inline HTML elements may be used: <strong><em><pre><q><blockquote><code>. All other code will get removed before posting. Don't forget to close your tags.


Search the archive

Stylegala news archive

Public news archive

News contributors


Features

Stylegala BookStore
The Stylegala BookStore has a massive archive of great books for you as a professional..
Bullet madness
Bullet madness is a list of 200 bullets, arrows and icons uploaded by our users.
CSS Reference
An alphabetical list over the most common CSS1 and CSS2 syntax and properties.

Sponsors

Logo design for $149

Advertise here