Hacker News new | ask | show | jobs
by Stratoscope 4093 days ago
It's very kind of John to mention my first jQuery plugin in the notes.

Unfortunately, it was not a very good plugin and probably set a bad precedent.

Like so many new jQuery developers, I went "Chaining? Whoa. Chain all the things!"

So I attached the plugin to $.fn, not thinking about the fact that what the plugin did had very little to do with the current element selection.

I may have been the first to make this mistake, but at least I wasn't the last. :-)

Perhaps I redeemed myself by coming up with the idea to use $.prototype for plugin methods instead of copying the method references by looping through $.fn (we kept $.fn as an alias of $.prototype for compatibility). So a $(...) call became a lot faster.

1 comments

I suspect a lot of the "unnecessary chaining" that occurs is really a problem of people (A) making something that requires jQuery and they don't want to think about how to ensure that dependency, while (B) liking the idea of associating their little thing with a big-name project.

Then you get things like $("#target").MakeBobsFancyBoxWidget()