NPM - NPM is a package manager for the JavaScript programming language. You can install tiny-events.js using the following command YARN - Yarn is anot

sachinchoolur / tiny-events.js

submited by
Style Pass
2021-08-03 14:30:04

NPM - NPM is a package manager for the JavaScript programming language. You can install tiny-events.js using the following command

YARN - Yarn is another popular package manager for the JavaScript programming language. If you prefer you can use Yarn instead of NPM

Event delegation is an event handling technique where, instead of attaching event handlers directly to every element you want to listen to events on, you attach a single event handler to a parent element of those elements to listen for events occurring on it’s descendant elements

By passing a selector as the second argument to on() method, the event handler will fire only if the event is triggered on the selector

I built the initial version of tinyEvents during the development of lightGallery. lightGallery 2.0 is completely re-written from scratch in vanilla JavaScript which was dependent on jQuery earlier. It was very difficult to keep track of all event listeners, making use of event delegation, and using custom events in vanilla JS while it is very easy with jQuery. So I wrote this tiny library which supports jQuery-like syntax and functionalities and is still less than 1 kb.

P.S. I'm working on an other tool that automatically finds and replaces jQuery methods with vanilla javascript methods. Watch the repo to get notified

Leave a Comment
Related Posts