Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
* jQuery Tiny Pub/Sub - v0.2pre - 11/3/2010
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
(function ($) {
var bind = $.fn.bind, unbind = $.fn.unbind, trigger = $.fn.trigger, win = {
"0": window,
"length": 1
$.subscribe = function () {
bind.apply(win, arguments);
$.unsubscribe = function () {
unbind.apply(win, arguments);
$.publish = function () {
trigger.apply(win, arguments);

Not tiny enough! :P


BTW I just made it slightly smaller/better:


I know, I had far too much fun with this. If anything, I suppose it could be considered a testament to jQuery's powerful use of duck-typing. :)

I like your updated version better, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.