Stumbling across Juriy Zaytsev’s Event Counter Bookmarklet I decided to do a bit of debugging of an internal data analyst application current under development, and to my astonishment discovered that after a few minutes within the application I had nearly 4,000 Event observers hanging around. Granted, this application handles editing of rather complex documents, but something wasn’t getting cleaned out properly. After manually digging out the low hanging fruit, I had managed to drop half of those dangling observers, but I was still missing quite a few, and over time these smaller leaks were bound to bog down the application. I decided I needed a bookmarklet with a bit finer grain, that could enumerate the types of observers in the document. Building upon Juriy’s use of the inject method of Prototype Enumerables I built the following simple script:
Which you can grab with this bookmarklet.
This bookmarklet produces a popup with an enumerated list of observers by type: