Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] Efficiency of innerHTML over DOM tree manipulation
- From: sclay at ufl.edu (Steve Clay)
- Subject: [Javascript] Efficiency of innerHTML over DOM tree manipulation
- Date: Wed Jun 28 07:33:25 2006
Wednesday, June 28, 2006, 7:15:32 AM, Matt wrote:
> Is either method more efficient than the other?
Browsers are Really Good at parsing markup so innerHTML is almost always
faster. That said, I would recommend adding all the needed elements in one
shot rather than calling innerHTML in a loop. Also, if you're building
markup by concatenating strings in a loop, you might get better performance
by adding each chunk to an array then joining at the end:
markup = [];
while(loop) {
markup.push('<!-- markup here-->');
}
target.innerHTML = markup.join('');
BTW, the "standard version" of innerHTML is a bit messy and way
undersupported: http://www.grauw.nl/blog/entry/179
Steve
--
http://mrclay.org/
- Follow-Ups:
- [Javascript] Efficiency of innerHTML over DOM tree manipulation
- From: Rakesh Pai
- [Javascript] Efficiency of innerHTML over DOM tree manipulation
- References:
- [Javascript] Efficiency of innerHTML over DOM tree manipulation
- From: Matt Barton
- [Javascript] Efficiency of innerHTML over DOM tree manipulation
- Prev by Date: [Javascript] Re: sounds IE tested worikng!
- Next by Date: [Javascript] Efficiency of innerHTML over DOM tree manipulation
- Previous by thread: [Javascript] Efficiency of innerHTML over DOM tree manipulation
- Next by thread: [Javascript] Efficiency of innerHTML over DOM tree manipulation
- Index(es):