<?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: Fast DOM Queries in Today&#8217;s Browsers</title>
	<atom:link href="http://alex.dojotoolkit.org/2006/03/fast-dom-queries-in-todays-browsers/feed/" rel="self" type="application/rss+xml" />
	<link>http://alex.dojotoolkit.org/2006/03/fast-dom-queries-in-todays-browsers/</link>
	<description>Alex Russell's notes on Dojo, Chrome, politics, and the like</description>
	<lastBuildDate>Mon, 29 Jun 2009 18:33:25 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Tercüme bürosu</title>
		<link>http://alex.dojotoolkit.org/2006/03/fast-dom-queries-in-todays-browsers/comment-page-1/#comment-193779</link>
		<dc:creator>Tercüme bürosu</dc:creator>
		<pubDate>Tue, 30 Oct 2007 15:51:31 +0000</pubDate>
		<guid isPermaLink="false">http://alex.dojotoolkit.org/?p=550#comment-193779</guid>
		<description>That’s a great result! It works on nightly Safaris and Konq 3.5.1 as well.
Outstanding.</description>
		<content:encoded><![CDATA[<p>That’s a great result! It works on nightly Safaris and Konq 3.5.1 as well.<br />
Outstanding.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dojo.foo &#187; dojo.query: A CSS Query Engine For Dojo</title>
		<link>http://alex.dojotoolkit.org/2006/03/fast-dom-queries-in-todays-browsers/comment-page-1/#comment-77391</link>
		<dc:creator>dojo.foo &#187; dojo.query: A CSS Query Engine For Dojo</dc:creator>
		<pubDate>Sun, 04 Feb 2007 19:10:53 +0000</pubDate>
		<guid isPermaLink="false">http://alex.dojotoolkit.org/?p=550#comment-77391</guid>
		<description>[...] It&#8217;s an important goal, and ensuring that simple-looking queries don&#8217;t &#8220;hurt&#8221; disproportionately is a difficult task. After some initial work with my admittedly grotty getElementsById hack, my outlook wasn&#8217;t bright. Other systems weren&#8217;t looking much better. Using the behavior: expression(); hack degrades page performance something fierce and can&#8217;t be made synchronous, a key requirement to meet developer ease-of-use goals. Requiring a callback for every query result is a no-go. [...]</description>
		<content:encoded><![CDATA[<p>[...] It&#8217;s an important goal, and ensuring that simple-looking queries don&#8217;t &#8220;hurt&#8221; disproportionately is a difficult task. After some initial work with my admittedly grotty getElementsById hack, my outlook wasn&#8217;t bright. Other systems weren&#8217;t looking much better. Using the behavior: expression(); hack degrades page performance something fierce and can&#8217;t be made synchronous, a key requirement to meet developer ease-of-use goals. Requiring a callback for every query result is a no-go. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Diego Perini</title>
		<link>http://alex.dojotoolkit.org/2006/03/fast-dom-queries-in-todays-browsers/comment-page-1/#comment-63069</link>
		<dc:creator>Diego Perini</dc:creator>
		<pubDate>Thu, 07 Dec 2006 21:01:28 +0000</pubDate>
		<guid isPermaLink="false">http://alex.dojotoolkit.org/?p=550#comment-63069</guid>
		<description>Sorry for the mess...in the above example:

 &#160; document.body.childNodes

should be:

&#160;&#160; document.getElementsByTagName(&#039;*&#039;)

by cut &amp; paste I took it from the wrong example, but it works, have a look in my site I am updating it.

Diego</description>
		<content:encoded><![CDATA[<p>Sorry for the mess&#8230;in the above example:</p>
<p> &nbsp; document.body.childNodes</p>
<p>should be:</p>
<p>&nbsp;&nbsp; document.getElementsByTagName(&#8217;*')</p>
<p>by cut &amp; paste I took it from the wrong example, but it works, have a look in my site I am updating it.</p>
<p>Diego</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Diego Perini</title>
		<link>http://alex.dojotoolkit.org/2006/03/fast-dom-queries-in-todays-browsers/comment-page-1/#comment-62930</link>
		<dc:creator>Diego Perini</dc:creator>
		<pubDate>Thu, 07 Dec 2006 03:57:02 +0000</pubDate>
		<guid isPermaLink="false">http://alex.dojotoolkit.org/?p=550#comment-62930</guid>
		<description>This is what I have, works with Safari/Konqueror and all other browsers, is fast, very fast should say, and it does not remove the ID, should work on IE5/IE4.

The first query will fill the cache, from there on queries will be immediate.-

The full example is at: &lt;a href=&quot;http://javascript.nwbox.com/getElementsById/&quot; rel=&quot;nofollow&quot;&gt;my demo place&lt;/a&gt; if you want to see the timings.

Hope the cut &amp; paste works, enjoy and comment please.

Here goes the snippet:

/*
 * ElementsById
 *
 * Author: Diego Perini
 * Updated: 06/11/2006
 * Version: 0.0 (from parent)
 *
 * Extracted from latest versions of IPORT/STYLER engines.
 *
 * Returns an array of elements with specified ID.
 */
function ElementsById($id) {
    var c=0,i=0,j=0,k=0;
    var nodes=[],storage=arguments.callee.storage;
    var childrens=document.body.childNodes,len=childrens.length;

    // only BODY elements are checked, no HTML or HEAD nodes/subnodes
    if (storage &amp;&amp; storage.length &amp;&amp; storage.length != 0) {
        k = $id;
        while (storage[k]) {
            nodes[nodes.length] = storage[k];
            k = $id + &#039;_&#039; + (++i);
        }
    } else {
        storage = { length: 0 };
        while (len &gt; i) {
            c = childrens[i];
            if ((k = c.id) == $id) {
                nodes[nodes.length] = c;
                if(storage[k]) {
                    k = c.id + &#039;_&#039; + (++j);
                }
            }
            i++;
            storage[k] = c;
            storage.length++;
        }
        arguments.callee.storage = storage;
    }
    return nodes;
}

</description>
		<content:encoded><![CDATA[<p>This is what I have, works with Safari/Konqueror and all other browsers, is fast, very fast should say, and it does not remove the ID, should work on IE5/IE4.</p>
<p>The first query will fill the cache, from there on queries will be immediate.-</p>
<p>The full example is at: <a href="http://javascript.nwbox.com/getElementsById/"  rel="nofollow">my demo place</a> if you want to see the timings.</p>
<p>Hope the cut &amp; paste works, enjoy and comment please.</p>
<p>Here goes the snippet:</p>
<p>/*<br />
 * ElementsById<br />
 *<br />
 * Author: Diego Perini<br />
 * Updated: 06/11/2006<br />
 * Version: 0.0 (from parent)<br />
 *<br />
 * Extracted from latest versions of IPORT/STYLER engines.<br />
 *<br />
 * Returns an array of elements with specified ID.<br />
 */<br />
function ElementsById($id) {<br />
    var c=0,i=0,j=0,k=0;<br />
    var nodes=[],storage=arguments.callee.storage;<br />
    var childrens=document.body.childNodes,len=childrens.length;</p>
<p>    // only BODY elements are checked, no HTML or HEAD nodes/subnodes<br />
    if (storage &amp;&amp; storage.length &amp;&amp; storage.length != 0) {<br />
        k = $id;<br />
        while (storage[k]) {<br />
            nodes[nodes.length] = storage[k];<br />
            k = $id + &#8216;_&#8217; + (++i);<br />
        }<br />
    } else {<br />
        storage = { length: 0 };<br />
        while (len &gt; i) {<br />
            c = childrens[i];<br />
            if ((k = c.id) == $id) {<br />
                nodes[nodes.length] = c;<br />
                if(storage[k]) {<br />
                    k = c.id + &#8216;_&#8217; + (++j);<br />
                }<br />
            }<br />
            i++;<br />
            storage[k] = c;<br />
            storage.length++;<br />
        }<br />
        arguments.callee.storage = storage;<br />
    }<br />
    return nodes;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eduardo Pereda</title>
		<link>http://alex.dojotoolkit.org/2006/03/fast-dom-queries-in-todays-browsers/comment-page-1/#comment-45399</link>
		<dc:creator>Eduardo Pereda</dc:creator>
		<pubDate>Wed, 13 Sep 2006 02:28:13 +0000</pubDate>
		<guid isPermaLink="false">http://alex.dojotoolkit.org/?p=550#comment-45399</guid>
		<description>Today I come across a problem with DOM manipulation performance and I tried your trick but didn&#039;t work for me.

My problem was that I had to resize almost all the rows of a table dynamically (it doesn&#039;t matter why, we needed this). The strategy was to iterate through all the rows setting the heights to the apropiate values.

This thing takes a *lot* of time. About 70 ms for a 600 rows table (= 42 seconds). 

After some fight with it, I managed to solve it hidding (style.display=&#039;none&#039;) the div containing the table before doing the resizing and showing it again afterwards (style.display=&#039;inline&#039;). This only little thing made the time drop to 2 ms per row (about 1.2 seconds). As you can see, a big improvement!

Aparently, Internet Explorer defers the DOM drawing/update until it is shown.

I hope this helps somebody!</description>
		<content:encoded><![CDATA[<p>Today I come across a problem with DOM manipulation performance and I tried your trick but didn&#8217;t work for me.</p>
<p>My problem was that I had to resize almost all the rows of a table dynamically (it doesn&#8217;t matter why, we needed this). The strategy was to iterate through all the rows setting the heights to the apropiate values.</p>
<p>This thing takes a *lot* of time. About 70 ms for a 600 rows table (= 42 seconds). </p>
<p>After some fight with it, I managed to solve it hidding (style.display=&#8217;none&#8217;) the div containing the table before doing the resizing and showing it again afterwards (style.display=&#8217;inline&#8217;). This only little thing made the time drop to 2 ms per row (about 1.2 seconds). As you can see, a big improvement!</p>
<p>Aparently, Internet Explorer defers the DOM drawing/update until it is shown.</p>
<p>I hope this helps somebody!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: erik</title>
		<link>http://alex.dojotoolkit.org/2006/03/fast-dom-queries-in-todays-browsers/comment-page-1/#comment-9949</link>
		<dc:creator>erik</dc:creator>
		<pubDate>Fri, 05 May 2006 08:12:06 +0000</pubDate>
		<guid isPermaLink="false">http://alex.dojotoolkit.org/?p=550#comment-9949</guid>
		<description>What about giving each element its own unique id but any elements you need to group provide a common prefix for?  e.g. id=&quot;group.1&quot;, id=&quot;group.2&quot;, id=&quot;group.3&quot; and simply have an integer that increments after you lookup each element by id until an element isn&#039;t found?

Your ids are all still unique and you get the performance boost of getElementById().</description>
		<content:encoded><![CDATA[<p>What about giving each element its own unique id but any elements you need to group provide a common prefix for?  e.g. id=&#8221;group.1&#8243;, id=&#8221;group.2&#8243;, id=&#8221;group.3&#8243; and simply have an integer that increments after you lookup each element by id until an element isn&#8217;t found?</p>
<p>Your ids are all still unique and you get the performance boost of getElementById().</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://alex.dojotoolkit.org/2006/03/fast-dom-queries-in-todays-browsers/comment-page-1/#comment-5615</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Wed, 19 Apr 2006 11:32:44 +0000</pubDate>
		<guid isPermaLink="false">http://alex.dojotoolkit.org/?p=550#comment-5615</guid>
		<description>Please read Pavan Keely&#039;s blog 
http://keelypavan.blogspot.com/2006/04/faster-way-of-accessing-dom-elements.html . He gives a simple solution-no need for this &quot;hideous&quot; ( as someone has mentioned ) solution.</description>
		<content:encoded><![CDATA[<p>Please read Pavan Keely&#8217;s blog<br />
<a href="http://keelypavan.blogspot.com/2006/04/faster-way-of-accessing-dom-elements.html"  rel="nofollow">http://keelypavan.blogspot.com/2006/04/faster-way-of-accessing-dom-elements.html</a> . He gives a simple solution-no need for this &#8220;hideous&#8221; ( as someone has mentioned ) solution.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tapper</title>
		<link>http://alex.dojotoolkit.org/2006/03/fast-dom-queries-in-todays-browsers/comment-page-1/#comment-5610</link>
		<dc:creator>Tapper</dc:creator>
		<pubDate>Sat, 15 Apr 2006 20:26:46 +0000</pubDate>
		<guid isPermaLink="false">http://alex.dojotoolkit.org/?p=550#comment-5610</guid>
		<description>Hacking with ID and breaking its uniqueness has other side-effects including potentially screwing up CSS as well as linking since ID is used in those technologies as well.  

I think the need for speed and appropriate collections to apply behaviors to is worthy, but this is surely not a reasonable way to accomplish it.</description>
		<content:encoded><![CDATA[<p>Hacking with ID and breaking its uniqueness has other side-effects including potentially screwing up CSS as well as linking since ID is used in those technologies as well.  </p>
<p>I think the need for speed and appropriate collections to apply behaviors to is worthy, but this is surely not a reasonable way to accomplish it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jacob Rockowitz</title>
		<link>http://alex.dojotoolkit.org/2006/03/fast-dom-queries-in-todays-browsers/comment-page-1/#comment-5609</link>
		<dc:creator>Jacob Rockowitz</dc:creator>
		<pubDate>Sat, 15 Apr 2006 15:57:36 +0000</pubDate>
		<guid isPermaLink="false">http://alex.dojotoolkit.org/?p=550#comment-5609</guid>
		<description>This is hack but if you set both ID and Name within a tag the elements will be properly collected by document.getElementsByName. 

&lt;B ID=&quot;example&quot; NAME=&quot;example&quot;&gt;Example 1&lt;/B&gt;
&lt;B ID=&quot;example&quot; NAME=&quot;example&quot;&gt;Example 2&lt;/B&gt;
&lt;SCRIPT&gt;
document.write(document.getElementsByName(&quot;example&quot;).length)
&lt;/SCRIPT&gt;</description>
		<content:encoded><![CDATA[<p>This is hack but if you set both ID and Name within a tag the elements will be properly collected by document.getElementsByName. </p>
<p>&lt;B ID=&quot;example&quot; NAME=&quot;example&quot;&gt;Example 1&lt;/B&gt;<br />
&lt;B ID=&quot;example&quot; NAME=&quot;example&quot;&gt;Example 2&lt;/B&gt;<br />
&lt;SCRIPT&gt;<br />
document.write(document.getElementsByName(&quot;example&quot;).length)<br />
&lt;/SCRIPT&gt;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jacob Rockowitz</title>
		<link>http://alex.dojotoolkit.org/2006/03/fast-dom-queries-in-todays-browsers/comment-page-1/#comment-5608</link>
		<dc:creator>Jacob Rockowitz</dc:creator>
		<pubDate>Sat, 15 Apr 2006 15:13:41 +0000</pubDate>
		<guid isPermaLink="false">http://alex.dojotoolkit.org/?p=550#comment-5608</guid>
		<description>This is hack but if you use both ID and Name within a tag the elements will be properly collected by document.getElementsByName.


Example 1

Example 2


document.write(document.getElementsByName(&quot;example&quot;).length)
</description>
		<content:encoded><![CDATA[<p>This is hack but if you use both ID and Name within a tag the elements will be properly collected by document.getElementsByName.</p>
<p>Example 1</p>
<p>Example 2</p>
<p>document.write(document.getElementsByName(&#8221;example&#8221;).length)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dustin Diaz</title>
		<link>http://alex.dojotoolkit.org/2006/03/fast-dom-queries-in-todays-browsers/comment-page-1/#comment-5606</link>
		<dc:creator>Dustin Diaz</dc:creator>
		<pubDate>Fri, 14 Apr 2006 21:59:18 +0000</pubDate>
		<guid isPermaLink="false">http://alex.dojotoolkit.org/?p=550#comment-5606</guid>
		<description>Why is it that I always miss shizzo like this. A month later here I am &quot;after the fact&quot; reading about a query like this and a discussion between Dean and Alex... posh.</description>
		<content:encoded><![CDATA[<p>Why is it that I always miss shizzo like this. A month later here I am &#8220;after the fact&#8221; reading about a query like this and a discussion between Dean and Alex&#8230; posh.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pavan Keely</title>
		<link>http://alex.dojotoolkit.org/2006/03/fast-dom-queries-in-todays-browsers/comment-page-1/#comment-4932</link>
		<dc:creator>Pavan Keely</dc:creator>
		<pubDate>Tue, 11 Apr 2006 17:19:40 +0000</pubDate>
		<guid isPermaLink="false">http://alex.dojotoolkit.org/?p=550#comment-4932</guid>
		<description>I apologize for that wrong statement &quot;But I have to agree with you that Forefox is not supporting Firefox&quot;..I meant,  &quot;But I have to agree with you that Firefox doesn&#039;t support document.all&quot;

Pavan Keely</description>
		<content:encoded><![CDATA[<p>I apologize for that wrong statement &#8220;But I have to agree with you that Forefox is not supporting Firefox&#8221;..I meant,  &#8220;But I have to agree with you that Firefox doesn&#8217;t support document.all&#8221;</p>
<p>Pavan Keely</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pavan Keely</title>
		<link>http://alex.dojotoolkit.org/2006/03/fast-dom-queries-in-todays-browsers/comment-page-1/#comment-4930</link>
		<dc:creator>Pavan Keely</dc:creator>
		<pubDate>Tue, 11 Apr 2006 17:15:56 +0000</pubDate>
		<guid isPermaLink="false">http://alex.dojotoolkit.org/?p=550#comment-4930</guid>
		<description>TI,

The problem of not showing up Divs in Firefox is because I am using innerText which is not supported in Firefox, in place of that if you try using document.createTextNode, it displays the Divs and Firefox does support appendChild on document.body. But I have to agree with you that Forefox is not supporting Firefox. I think I somehow missed it because my plan was to test in 3 diff browsers.

Pavan Keely</description>
		<content:encoded><![CDATA[<p>TI,</p>
<p>The problem of not showing up Divs in Firefox is because I am using innerText which is not supported in Firefox, in place of that if you try using document.createTextNode, it displays the Divs and Firefox does support appendChild on document.body. But I have to agree with you that Forefox is not supporting Firefox. I think I somehow missed it because my plan was to test in 3 diff browsers.</p>
<p>Pavan Keely</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TI</title>
		<link>http://alex.dojotoolkit.org/2006/03/fast-dom-queries-in-todays-browsers/comment-page-1/#comment-4869</link>
		<dc:creator>TI</dc:creator>
		<pubDate>Tue, 11 Apr 2006 14:11:21 +0000</pubDate>
		<guid isPermaLink="false">http://alex.dojotoolkit.org/?p=550#comment-4869</guid>
		<description>Pavan, I found your code wouldn&#039;t draw the div&#039;s under Firefox 1.5.0.1. Mozilla does not like appending child nodes to document.body. To confirm further I modified your code with a simple document.write and it does not like document.all either.

Meanwhile why do people feel the need to become so outraged? Alex put up the disclaimer that this was not a standards friendly manouver and even called it a &#039;hack&#039;. 

On the upside flaming does prompt some very informative justification posts. From Alex at least.</description>
		<content:encoded><![CDATA[<p>Pavan, I found your code wouldn&#8217;t draw the div&#8217;s under Firefox 1.5.0.1. Mozilla does not like appending child nodes to document.body. To confirm further I modified your code with a simple document.write and it does not like document.all either.</p>
<p>Meanwhile why do people feel the need to become so outraged? Alex put up the disclaimer that this was not a standards friendly manouver and even called it a &#8216;hack&#8217;. </p>
<p>On the upside flaming does prompt some very informative justification posts. From Alex at least.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: alex</title>
		<link>http://alex.dojotoolkit.org/2006/03/fast-dom-queries-in-todays-browsers/comment-page-1/#comment-4801</link>
		<dc:creator>alex</dc:creator>
		<pubDate>Mon, 10 Apr 2006 21:48:32 +0000</pubDate>
		<guid isPermaLink="false">http://alex.dojotoolkit.org/?p=550#comment-4801</guid>
		<description>Pavan and Dean,

That&#039;s a great result! It works on nightly Safaris and Konq 3.5.1 as well.

Outstanding.</description>
		<content:encoded><![CDATA[<p>Pavan and Dean,</p>
<p>That&#8217;s a great result! It works on nightly Safaris and Konq 3.5.1 as well.</p>
<p>Outstanding.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
