Showing posts from August, 2013

The Bling Chain

JQuery is the most popular JavaScript toolkit. But I think it's inherently flawed, and there are much better alternatives.

JQuery is a toolkit for manipulating the Document Object Model (DOM), i.e. the live editable tree structure that the browser creates from a webpage in its memory. It is useful for doing stuff like this:

The $ (bling) function looks for an element (crotch) in the DOM, and applies some functionality (sniff) to it. Since that function just returns the same element (crotch), you can run it again through another function (scratch). As a matter of fact, every other function returns the same element, so you can create a whole chain of functions (the bling chain). This means that the toolkit extends the element with some custom behavior. Nothing wrong with learning an old dog some new tricks. However, JQuery adds all this functionality in one single dirty file. In fact, JQuery just fails on the nice script above, because it do…