Reglib, an Event Delegation based Framework
by Pascal Opitz on November 14 2008, 22:50
Via the ajaxian I came across the javascript based framework reglib, written by Gregory Reimer. It is based on some very clever thoughts and makes heavy use of Event Delegation.
Event Delegation is a technique I used quite a lot at Tesco. Back then Matt Dunn, who was the lead UI developer there, introduced me to its benefits and how it helps to keep the memory footprint down.
reglib goes a step further. It utilizes the body element as single entry point for all events, and identifies the nodes that triggered the event so it can match them with functions that were assigned through the library and execute them.
This cuts out the wait for until the DOM is Loaded by the browser, something that is pretty much essential and implemented into most other frameworks like JQuery or MooTools. Gregory Reimer, who has written reglib based on his work for sun.com, seems to dislike this and even describes this as anti-pattern.
Comments
Although jQuery doesn't do this by nature (or it didn't do it back in February 08), some smart people have happily extended it.
One of them is Pub Standards own Dan Webb, using it in his LowPro project and offering a prototype version too: http://www.danwebb.net/2008/2/8/event-delegation-made-easy-in-jquery
Another one is scarily enough from around the same time AND it looks almost the same, on dev.distilldesign: http://dev.distilldesign.com/log/2008/jan/27/event-delegation-jquery/
by Matthias Willerich on November 19 2008, 09:46 #