Navigation

Home
Search
Submit A Resource
Contact Us
About Functionn

Subscription Options


Subscribe By Email (265+)


Lists


Archives

Nov 29, 2012

Author: Hirvesh Posted At: 11/29/2012 Tags: , , , , , , ,

gator.js - A JavaScript Library For Simple Event Delegation

Share:

Gator is a small (~0.78 kb minified + gzipped), simple, standalone, event delegation library.  If you are familiar with jQuery then it may look familiar to you.  Out of the box gator works in Chrome, Safari 5+, Firefox 3.6+, and Internet Explorer 9+. The legacy.js plugin adds support for Safari < 5, and Firefox < 3.6 and Internet Explorer 6, 7, and 8.


Why Use Event Delegation?

There are already a number of articles about event delegation and the advantages over traditional event handling. Here are just a few:

improved performance/memory usage - If you have a table with hundreds of cells, and you want to do something when the user clicks on a cell, without delegation you would have to bind the event to each cell. With delegation you could bind a single click handler to the table element.

No need to re-attach events - If you use AJAX to dynamically insert/update content on the current page then you don't have to worry about removing/adding the events every time the content changes. You can bind the events once to a higher level element.

Fewer functions to manage - Without delegation you would have to manage a lot of callback functions. If you remove a bunch of elements you would have to make sure to remove all the events associated with them.

Requirements: None
Demo: http://craig.is/riding/gators
License: Apache License v2.0

Daily Posts, Be Updated, Subscribe:

Want Free Web Resources? Enter Your Email And We'll Send It To You - Daily! (265+ Subscribers)

Yup, it's that straight forward! Enter your email address below and we'll send you the latest web resources to your inbox, everyday. We don't do spam. Ever.

Trending Posts On Functionn This Week

Share:

Other Interesting Resources:

0 comments:

Post a Comment

 


Recent Posts

Popular Categories



Popular Components



Popular Licenses