Chapter 14.5.3. Creating DOM Nodes
MochiKit.DOM makes it easy to create new DOM nodes. One use of this is to make an Ajax request for some information that comes back in JSON format and then format the result completely within the browser. Doing this kind of formatting by creating DOM nodes without MochiKit would be painful indeed. With MochiKit, however, itâ€™s easy and very readable.
Dynamically creating DOM nodes for new content seems like a clean way to update the page, and it is. However, itâ€™s not the best performing way to do it. Setting innerHTML on a DOM node performs better than creating a bunch of nodes in Java-Script and attaching them to that node. If you are displaying a lot of information, you might want to use innerHTML.