Working together for standards The Web Standards Project

DOM Builder

By Jeremy Keith | April 13th, 2006 | Filed in DOM, DOM Scripting TF

Now here’s a script we can get behind… Dan Webb’s DOM Builder combines the ease of innerHTML with the precision of DOM methods.

Skip to comment form

Dan Webb is a standards-savvy JavaScript developer who has run into a dilemma familiar to many of us…

Suppose you want to generate and insert some markup using JavaScript. You’ve got two options:

  1. You can use the non-standard innerHTML which is quick and easy but proprietary or
  2. You can use standards: DOM methods like createElement and createTextNode which carry the W3C’s stamp of approval but which can be finicky and repetitive to use.

Dan has resolved this conundrum by creating an elegant lightweight script to take the pain out of creating markup with JavaScript. He has provided documentation and he explains his reasons for writing the script.

Like all the best solutions, it does one thing really well instead of trying to be all things to all people. This 1K file will prove invaluable to anyone who’s been faced with the same dilemma. It’s a guilt-free way of painlessly adding nodes to the DOM tree.

Your Replies

#1 On April 13th, 2006 8:33 pm