[thelist] Question about memory leaks with Javascript and Ajax

Bill Moseley moseley at hank.org
Sat Mar 4 15:50:51 CST 2006

I'm new to javascript, but I have seen comments about memory leaks.
I'm wondering if I need to be concerned about what I'm doing.

This message was warnocked on the Behaviour list -- sorry for any

I have a table that I apply events to using Behaviour.

For example:

    Behaviour.register( {
        '#matrix td a' : function(e){
            addEvent(e, 'click', stop_bubble, false );
            e.onclick = function() {
                return true;
    } );

Now, that #matrix div can be completely replaced by an Ajax call (using
Ajax.Updater) -- the table's headings can be clicked to sort by a
column, for example, and the table is updated in-place.

In the Ajax.Updater call I specify an onComplete action of
"Behaviour.apply" to reapply the actions to the newly replaced table.

So, what I'm curious about is when I replace the table with the Ajax
call do I have to worry about those (old) events added to the original
table?  That is, do updates to the DOM take care of garbage

Bill Moseley
moseley at hank.org

More information about the thelist mailing list