Monday, February 23rd, 2009

Watching Prototype events and a nice little tip

Category: Prototype, Tip

Kangax shows a nice use of Prototype as he writes a tip to let you see your Prototype based events as they run in your application. A nice little view.

He also realized that the core piece of the bookmarklet is actually a nice view of the power of Prototype as a library:

< view plain text >
  1. $H(Event.cache).inject(0, function(m, p) {
  2.   m += $H(p.value).values().flatten().size();
  3.   return m;
  4. });

Posted by Dion Almaer at 6:56 am

3 rating from 25 votes


Comments feed TrackBack URI

I believe kangax’s script will give an inaccurate result because it doesn’t filter out the `element` object in the cache.
Here is a corrected version that doesn’t use `inject` and, as a result, is ~1,107% faster.

Comment by jdalton — February 23, 2009

Note: The Event.cache `element` property is only on some edge versions of Prototype from ~August 08.
One example of this is found on Lighthouse pages, .

Comment by jdalton — February 23, 2009

Leave a comment

You must be logged in to post a comment.