For the first time in a couple of weeks I’m releasing a new thing: Cliche.js. It’s a small library for mapping JavaScript click events. Instead of having to use document.querySelector and target.addEventListener over and over again1 you can do this:

var someFunction = function(selector) {
  // ...

var anotherFunction = function(selector, event) {
  var target =;
  // ...

  '#some-selector'    : someFunction,
  '#another-selector' : anotherFunction

I think it looks pretty neat. For simplicity it currently only supports IE9+, but you can easily use a couple of polyfills to get it to work in other browsers. with a few selected event listeners instead.

  1. Although if you’re mapping a lot of events you probably should be using 

comments powered by Disqus