Perfection Kills

by kangax

Engineering, fitness, and everything in between

← All posts

Event delegation will save the world

Event delegation will save the world

If you ever wanted to know how many event handlers your Prototype.js-based application has, but were afraid to count, this tiny bookmarklet will gladly do that for you!

Accidentally, the snippet demonstrates an absolutely wicked use of Prototype’s sacred technique of inject over Hash.


$H(Event.cache).inject(0, function(m, p) {
  m += $H(p.value).values().flatten().size();
  return m;
});

Enjoy.

Comments