<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: DHTML versus DOM: Comparing Both Approaches</title>
	<atom:link href="http://ajaxian.com/archives/dhtml-versus-dom-comparing-both-approaches/feed" rel="self" type="application/rss+xml" />
	<link>http://ajaxian.com/archives/dhtml-versus-dom-comparing-both-approaches</link>
	<description>Cleaning up the web with Ajax</description>
	<lastBuildDate>Thu, 09 Feb 2012 06:55:33 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
	<item>
		<title>By: Dave Stewart</title>
		<link>http://ajaxian.com/archives/dhtml-versus-dom-comparing-both-approaches/comment-page-1#comment-256831</link>
		<dc:creator>Dave Stewart</dc:creator>
		<pubDate>Wed, 10 Oct 2007 08:59:35 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=1089#comment-256831</guid>
		<description>Every time I come back to looking at code I wrote the DOM way, I just have to &quot;trust&quot; I wrote it well in the first place, as it&#039;s more difficult to scan it and see what it represents. And if you want to change something even minor, it can be hard work.

The fact that it&#039;s orders or magnitude quicker to write or edit a bit of decent HTML than it is to laboriously create a DOM structure sells it for me (almost) every time.

I don&#039;t understand why people are saying &quot;DOM is the better way&quot;. Why &lt;i&gt;better&lt;/i&gt;?
As far as I see it, if I&#039;m writing semantically-correct markup, that works correctly in whatever application / browser I&#039;m working in, where&#039;s the problem? It&#039;s way more manageable, and slashes development time (so I can go and work on some REAL bugs!) and that&#039;s the key thing.

Any static HTML page is written using raw markup; we don&#039;t ask people to build it node by node, so what are the &quot;Oh you must build the DOM manually&quot; evangelists talking about?

Grrrr.....</description>
		<content:encoded><![CDATA[<p>Every time I come back to looking at code I wrote the DOM way, I just have to &#8220;trust&#8221; I wrote it well in the first place, as it&#8217;s more difficult to scan it and see what it represents. And if you want to change something even minor, it can be hard work.</p>
<p>The fact that it&#8217;s orders or magnitude quicker to write or edit a bit of decent HTML than it is to laboriously create a DOM structure sells it for me (almost) every time.</p>
<p>I don&#8217;t understand why people are saying &#8220;DOM is the better way&#8221;. Why <i>better</i>?<br />
As far as I see it, if I&#8217;m writing semantically-correct markup, that works correctly in whatever application / browser I&#8217;m working in, where&#8217;s the problem? It&#8217;s way more manageable, and slashes development time (so I can go and work on some REAL bugs!) and that&#8217;s the key thing.</p>
<p>Any static HTML page is written using raw markup; we don&#8217;t ask people to build it node by node, so what are the &#8220;Oh you must build the DOM manually&#8221; evangelists talking about?</p>
<p>Grrrr&#8230;..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jack</title>
		<link>http://ajaxian.com/archives/dhtml-versus-dom-comparing-both-approaches/comment-page-1#comment-246622</link>
		<dc:creator>jack</dc:creator>
		<pubDate>Mon, 29 Jan 2007 03:55:42 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=1089#comment-246622</guid>
		<description>Personally i think DOM is a better way</description>
		<content:encoded><![CDATA[<p>Personally i think DOM is a better way</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://ajaxian.com/archives/dhtml-versus-dom-comparing-both-approaches/comment-page-1#comment-245365</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Tue, 19 Dec 2006 00:45:38 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=1089#comment-245365</guid>
		<description>Very useful article, thanks!</description>
		<content:encoded><![CDATA[<p>Very useful article, thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ed Purkiss</title>
		<link>http://ajaxian.com/archives/dhtml-versus-dom-comparing-both-approaches/comment-page-1#comment-20054</link>
		<dc:creator>Ed Purkiss</dc:creator>
		<pubDate>Mon, 05 Jun 2006 19:56:40 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=1089#comment-20054</guid>
		<description>I see innerHTML to DOM as the &quot;exec&quot; function is to PHP. It has a very strong place in the language and is an excellent tool - to but endeavor to claim one superior to the other is like saying a hammer is superior to a screw driver.</description>
		<content:encoded><![CDATA[<p>I see innerHTML to DOM as the &#8220;exec&#8221; function is to PHP. It has a very strong place in the language and is an excellent tool &#8211; to but endeavor to claim one superior to the other is like saying a hammer is superior to a screw driver.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Heilmann</title>
		<link>http://ajaxian.com/archives/dhtml-versus-dom-comparing-both-approaches/comment-page-1#comment-7114</link>
		<dc:creator>Chris Heilmann</dc:creator>
		<pubDate>Tue, 18 Apr 2006 11:08:59 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=1089#comment-7114</guid>
		<description>Hmm, it is interesting to see how many people aren&#039;t even bothering to read an article before answering a lot about their likes and dislikes. 

The article is not about DOM generation vs. innerHTML, it has so many more points why DHTML is less efficient now and what the benefits of using DOM methods are. It is not only technical, it is also about the way to approach an HTML changing task with JavaScript.

I am writing a book on the matter now and am well aware of the benefits of innerHTML when it comes to XHR returns output and heavy application development. So, please before you wrap up in the &quot;but it is too handy to miss&quot; cocoon, have a read and then judge the article or make assumptions as to where I am standing in the debate afterwards.  :-)</description>
		<content:encoded><![CDATA[<p>Hmm, it is interesting to see how many people aren&#8217;t even bothering to read an article before answering a lot about their likes and dislikes. </p>
<p>The article is not about DOM generation vs. innerHTML, it has so many more points why DHTML is less efficient now and what the benefits of using DOM methods are. It is not only technical, it is also about the way to approach an HTML changing task with JavaScript.</p>
<p>I am writing a book on the matter now and am well aware of the benefits of innerHTML when it comes to XHR returns output and heavy application development. So, please before you wrap up in the &#8220;but it is too handy to miss&#8221; cocoon, have a read and then judge the article or make assumptions as to where I am standing in the debate afterwards.  :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Smith</title>
		<link>http://ajaxian.com/archives/dhtml-versus-dom-comparing-both-approaches/comment-page-1#comment-7017</link>
		<dc:creator>Paul Smith</dc:creator>
		<pubDate>Sun, 16 Apr 2006 16:36:43 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=1089#comment-7017</guid>
		<description>The server keeps timing out so I can&#039;t read the article, but most of the responses here seem to prefer innerHTML. I think that innerHTML and DOM manipulation are both useful depending on the situation.

There are many sites with DOM vs innerHTML performance tests, and DOM  is usually slower, but still pretty fast as long as you create fragments and append them to the body as the last step. See http://www.developer-x.com/content/innerhtml/dom_vs_innerHTML_perf_test.html for example.

DOM is nice if you want to keep around pointers to the elements you have created. With many dynamically updatable parts of the page it&#039;s nice to already have a pointer to the object instead of needing to call slow getElementById - especially if one request can update many seperate parts.

If you use bunch of function calls to make the HTML structure, DOM is nicer (for me at least) from a coding and maintenance perspective - creating strings from a bunch of different functions and remembering to create the ending tags is a bit messier. Reminds me of the good old days of using PERL on the server - before we had nice html template librarys.

On the other hand, if your javascript is just creating a bunch of static content, then innerHTML is cleaner and faster.</description>
		<content:encoded><![CDATA[<p>The server keeps timing out so I can&#8217;t read the article, but most of the responses here seem to prefer innerHTML. I think that innerHTML and DOM manipulation are both useful depending on the situation.</p>
<p>There are many sites with DOM vs innerHTML performance tests, and DOM  is usually slower, but still pretty fast as long as you create fragments and append them to the body as the last step. See <a href="http://www.developer-x.com/content/innerhtml/dom_vs_innerHTML_perf_test.html" rel="nofollow">http://www.developer-x.com/content/innerhtml/dom_vs_innerHTML_perf_test.html</a> for example.</p>
<p>DOM is nice if you want to keep around pointers to the elements you have created. With many dynamically updatable parts of the page it&#8217;s nice to already have a pointer to the object instead of needing to call slow getElementById &#8211; especially if one request can update many seperate parts.</p>
<p>If you use bunch of function calls to make the HTML structure, DOM is nicer (for me at least) from a coding and maintenance perspective &#8211; creating strings from a bunch of different functions and remembering to create the ending tags is a bit messier. Reminds me of the good old days of using PERL on the server &#8211; before we had nice html template librarys.</p>
<p>On the other hand, if your javascript is just creating a bunch of static content, then innerHTML is cleaner and faster.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joseph Annino</title>
		<link>http://ajaxian.com/archives/dhtml-versus-dom-comparing-both-approaches/comment-page-1#comment-7015</link>
		<dc:creator>Joseph Annino</dc:creator>
		<pubDate>Sun, 16 Apr 2006 16:12:03 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=1089#comment-7015</guid>
		<description>I&#039;ve found the best approach is to make up an HTML &quot;template&quot; that contains all the structure my page will ever need.  If there are multiple alternate views, I code them all as HTML, and use CSS rules to choose which one is shown.  If an element repeats, I specify it once within the HTML, inside a holder div, and copy it several times.

This is where the speed issue comes in.  Using the DOM methods (cloneNode, appendChild) is really slow in IE, and also buggy (its fine in Firefox though).  But if I get the outerHTML and repeat it in a string and stuff it into the innerHTML of the holder div its fast (in all browsers).   Then I can go through the new children and set styles, image sources, and such.

So I never &quot;generate&quot; html, I always use what is already there and just throw data into it and change its display properties.  The repeating elements are the one sort of exception, and I&#039;m wondering what others have found as the best approach for doing that sort of thing.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve found the best approach is to make up an HTML &#8220;template&#8221; that contains all the structure my page will ever need.  If there are multiple alternate views, I code them all as HTML, and use CSS rules to choose which one is shown.  If an element repeats, I specify it once within the HTML, inside a holder div, and copy it several times.</p>
<p>This is where the speed issue comes in.  Using the DOM methods (cloneNode, appendChild) is really slow in IE, and also buggy (its fine in Firefox though).  But if I get the outerHTML and repeat it in a string and stuff it into the innerHTML of the holder div its fast (in all browsers).   Then I can go through the new children and set styles, image sources, and such.</p>
<p>So I never &#8220;generate&#8221; html, I always use what is already there and just throw data into it and change its display properties.  The repeating elements are the one sort of exception, and I&#8217;m wondering what others have found as the best approach for doing that sort of thing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrey Skvortsov</title>
		<link>http://ajaxian.com/archives/dhtml-versus-dom-comparing-both-approaches/comment-page-1#comment-7011</link>
		<dc:creator>Andrey Skvortsov</dc:creator>
		<pubDate>Sun, 16 Apr 2006 12:41:21 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=1089#comment-7011</guid>
		<description>Scott,if you like E4X/XQuery like constructors then you like .innerHTML.
Currently,we don&#039;t have native construction set for DOM and innerHTML nice alternative in most cases(simply &quot;string&quot; framework is more mature;-).I believe you need to resort to DOM API only in rare cases for very granular manipulations.</description>
		<content:encoded><![CDATA[<p>Scott,if you like E4X/XQuery like constructors then you like .innerHTML.<br />
Currently,we don&#8217;t have native construction set for DOM and innerHTML nice alternative in most cases(simply &#8220;string&#8221; framework is more mature;-).I believe you need to resort to DOM API only in rare cases for very granular manipulations.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott Schiller</title>
		<link>http://ajaxian.com/archives/dhtml-versus-dom-comparing-both-approaches/comment-page-1#comment-7001</link>
		<dc:creator>Scott Schiller</dc:creator>
		<pubDate>Sun, 16 Apr 2006 01:57:52 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=1089#comment-7001</guid>
		<description>I think you can still get pretty good results with DOM provided you take the right approach - ie. creating an element structure &quot;off-line&quot;, making all necessary changes and finally making a single append to the body etc. Logically thinking, the browser should only have to reflow one set of elements much in the same way .innerHTML would. It is likely that looping through newly-created elements, setting event handlers and properties etc. contributes a lot to the overall difference in performance.

&quot;.innerHTML vs DOM&quot; might have been a more accurate title.
</description>
		<content:encoded><![CDATA[<p>I think you can still get pretty good results with DOM provided you take the right approach &#8211; ie. creating an element structure &#8220;off-line&#8221;, making all necessary changes and finally making a single append to the body etc. Logically thinking, the browser should only have to reflow one set of elements much in the same way .innerHTML would. It is likely that looping through newly-created elements, setting event handlers and properties etc. contributes a lot to the overall difference in performance.</p>
<p>&#8220;.innerHTML vs DOM&#8221; might have been a more accurate title.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gabriel</title>
		<link>http://ajaxian.com/archives/dhtml-versus-dom-comparing-both-approaches/comment-page-1#comment-6991</link>
		<dc:creator>Gabriel</dc:creator>
		<pubDate>Sat, 15 Apr 2006 18:27:24 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=1089#comment-6991</guid>
		<description>I&#039;ve found that using the DHTML method of using innerHTML is superior many times from a coding and maintenance point of view to using the DOM api.  Creating every element, then appending it into a container, then setting properties on it, can end up being a nightmare to maintain when the alternative is defining the end HTML you want and painting that into an element using innerHTML.

My vote:  innerHTML always, except when you can only do something using DOM element creation (which for me has been very rarely).</description>
		<content:encoded><![CDATA[<p>I&#8217;ve found that using the DHTML method of using innerHTML is superior many times from a coding and maintenance point of view to using the DOM api.  Creating every element, then appending it into a container, then setting properties on it, can end up being a nightmare to maintain when the alternative is defining the end HTML you want and painting that into an element using innerHTML.</p>
<p>My vote:  innerHTML always, except when you can only do something using DOM element creation (which for me has been very rarely).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason Haley</title>
		<link>http://ajaxian.com/archives/dhtml-versus-dom-comparing-both-approaches/comment-page-1#comment-6958</link>
		<dc:creator>Jason Haley</dc:creator>
		<pubDate>Sat, 15 Apr 2006 13:44:25 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=1089#comment-6958</guid>
		<description>&lt;strong&gt;Interesting Finds&lt;/strong&gt;

</description>
		<content:encoded><![CDATA[<p><strong>Interesting Finds</strong></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matthew Ratzloff</title>
		<link>http://ajaxian.com/archives/dhtml-versus-dom-comparing-both-approaches/comment-page-1#comment-6929</link>
		<dc:creator>Matthew Ratzloff</dc:creator>
		<pubDate>Fri, 14 Apr 2006 23:31:58 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=1089#comment-6929</guid>
		<description>Interesting.  I&#039;ve always been under the impression that all the dynamic JavaScript I write (whether via DOM or DHTML) is implied under the umbrella term of DHTML.  I wasn&#039;t aware that someone had made a differentiation at some point.  Can someone send me an invite to the Web application terminology mailing list so I can keep up to date with the new buzzwords?  Thanks.

Also, Chris C. is right.  I use DOM as much as possible, but it is often pathetically slow in anything even mildly rigorous.</description>
		<content:encoded><![CDATA[<p>Interesting.  I&#8217;ve always been under the impression that all the dynamic JavaScript I write (whether via DOM or DHTML) is implied under the umbrella term of DHTML.  I wasn&#8217;t aware that someone had made a differentiation at some point.  Can someone send me an invite to the Web application terminology mailing list so I can keep up to date with the new buzzwords?  Thanks.</p>
<p>Also, Chris C. is right.  I use DOM as much as possible, but it is often pathetically slow in anything even mildly rigorous.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris C</title>
		<link>http://ajaxian.com/archives/dhtml-versus-dom-comparing-both-approaches/comment-page-1#comment-6908</link>
		<dc:creator>Chris C</dc:creator>
		<pubDate>Fri, 14 Apr 2006 17:29:16 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=1089#comment-6908</guid>
		<description>My only problem with using the DOM API over innerHTML is the very poor performance.  Script is simply not fast.  Not fast enough to generate any modest amount of UI via the DOM.  Every time I&#039;ve tried to use it to generate UI it is rediculously slow compared to the instant native C++ speed of allowing the browser to render it via innerHTML.</description>
		<content:encoded><![CDATA[<p>My only problem with using the DOM API over innerHTML is the very poor performance.  Script is simply not fast.  Not fast enough to generate any modest amount of UI via the DOM.  Every time I&#8217;ve tried to use it to generate UI it is rediculously slow compared to the instant native C++ speed of allowing the browser to render it via innerHTML.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

