Re: What's faster, saving an HTML DOM node as a variable, or using getElementById?
- From: "RobG" <rgqld@xxxxxxxxxxxx>
- Date: 15 Sep 2006 08:08:58 -0700
Laurent Bugnion wrote:
Hi,
scriptguru@xxxxxxxxx wrote:
Be careful with cashing node references. getElementById can be slightly
slower but also it is always safer.
For example we saved some node reference in variable. Then we modified
document.body.innerHTML. Reference we saved is dead now.
Val Polyakh
Actually, it's worse than just dead, it's a zombie, a reference to an
object which won't be garbage-collected unless you set it explicitly to
null. That could be the source of many a memory leak.
That's not a memory leak, it's just poor coding - the memory will be
released when the page is replaced. Obviously if you are going to
store references you need to manage them.
--
Rob
.
- References:
- Prev by Date: Re: How do i re-assign a parentNode
- Next by Date: Re: I don't think that an iframe is a popup
- Previous by thread: Re: What's faster, saving an HTML DOM node as a variable, or using getElementById?
- Next by thread: setting focus to a tabe cell.
- Index(es):
Relevant Pages
|