J
Java script Dude
When building HTML in JavaScript when using JS DOM
(document.createElement(strType)) is not effective, there are
basically two methods for doing this:
1) Concatenate Strings:
var s="";
s+="<some_html>";
s+="<some_more_html>"//...
someElem.innerHTML=s
~
2) Build Using Arrays:
var a=[];
a.push("<some_html>");
a.push("<_more_html>");
someElem.innerHTML=a.join("")
~
I have reviewed code from several enterprise JavaScript based sites
and find a mixture of both methods.
Doing some simple performance testing I found that Internet Explorer
is ~3 faster with Arrays than Strings. Mozilla is ~2.5 times faster
with Strings than Arrays.
Has anybody done similar tests and what were your results and your
decision for your applications.
JsD
(document.createElement(strType)) is not effective, there are
basically two methods for doing this:
1) Concatenate Strings:
var s="";
s+="<some_html>";
s+="<some_more_html>"//...
someElem.innerHTML=s
~
2) Build Using Arrays:
var a=[];
a.push("<some_html>");
a.push("<_more_html>");
someElem.innerHTML=a.join("")
~
I have reviewed code from several enterprise JavaScript based sites
and find a mixture of both methods.
Doing some simple performance testing I found that Internet Explorer
is ~3 faster with Arrays than Strings. Mozilla is ~2.5 times faster
with Strings than Arrays.
Has anybody done similar tests and what were your results and your
decision for your applications.
JsD