mozilla/fireplace — pull request #175 by mattbasta (2013-06-13 00:37:41+00:00)
Title: Make explicit event handlers delegated

Some optimizations to help with event listener leakage. We're still leaking one or two, but this seems to clean up the vast majority of them. Memory usage now gets almost entirely freed on GC.

![screen shot 2013-06-12 at 5 30 42 pm](https://f.cloud.github.com/assets/279498/646220/8a217dcc-d3c0-11e2-8872-1f96ec716930.png)

- The very left is during Marketplace initialization (waiting for the XHRs to complete)
- The first jump is category rendering, which is why the document count quickly drops (the document fragment is merged into the DOM)
- The three steps up in red are the individual defer blocks being built. The corresponding tiny increase in green is the placeholders getting filled.
- The jumps in purple after the red goes up is my first navigation to another page
- At the very right is a sharp decrease. That's a forced garbage collection on my part (it would have happened naturally on its own). Notice that the event listeners dip to just above where they were when the page first rendered (42 at site load up to 44 after GC).
- The remaining two event listeners were for a Flipsnap on the previous page. We keep a reference around to the previous builder object (Bob J. Sr.), so that accounts for those not being cleaned up.

Notice that the site's memory footprint never climbs above 15mb.

cc @spasovski @muffinresearch