In comp.lang.javascript message <12voa7litf9dh5a@corp.supernews.com>,
Sat, 17 Mar 2007 13:44:29, Gérard Talbot <newsblahgroup@gtalbot.org>
posted:
Quote:
>On top of what Lee said...
>
>You should not use innerHTML to replace a text node. This is slower and
>more memory demanding than childNodes[0].nodeValue or
>firstChild.nodeValue or childNodes[0].data or even replaceData(offset,
>count, arg in DOMString)
>
>Speed and Performance comparison between innerHTML attribute and DOM's
>nodeValue
>
http://www.gtalbot.org/DHTMLSection/...NodeValue.html The page claims "at least 200% slower on ... Internet Explorer 6+" - in
IE6 and IE7 (on differing machines), I get only 50% slower - times
typically 125 & 187.
But the nodeValue code could I think be made faster by changing (I've
shortened identifiers; untested) from
{
if(a[i].childNodes[0] && a[i].childNodes[0].nodeType == 3)
{
a[i].childNodes[0].nodeValue = "Now ... nodeValue";
};
};
to
{
if ( (T=a[i].childNodes[0]) && T.nodeType == 3)
{
T.nodeValue = "Now ... nodeValue";
};
};
Comparison of speeds for changing arbitrary items (not sequentially
named, for example) could be useful in addition, preferably using a
function such as Wryt(ID, Str) {} but with different bodies.
--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.