I’m John K. Paul
an engineering manager
and a speaker

found on

contact at

john@johnkpaul.com

about me

Often an engineering manager, with many more interests than that

Subscribe to the Monthly Newsletter

powered by TinyLetter

Demystifying jQuery’s .index()

- - | Comments

Compared to everything in the jQuery external API, for a reason which I cannot completely pin down, .index() has always required me to look into the source to understand. I’m going to use this post to break down the four possible method signatures and possible use cases for myself, as well as anyone else who has every shared my confusion. I’m crossing my fingers that after I’m done, I’ll have this completely understood.

Changing jsFiddle’s Default Library to jQuery

- - | Comments

jsFiddle is awesome and I can’t say it enough. It has become the de facto mechanism to share snippets of javascript/html/css on the web, and I love that it’s so easy to use. It’s the fastest way to try out a new idea, show someone else a problem that you’re having, or just spend some time playing. I’m really grateful to Piotr Zalewa for spending so much time in making it such a great tool.

Since I use jsFiddle so much, I’m bound to find an annoyance or two though. I have found that I very often forget to switch away from the default js library, MooTools. It’s starting to become muscle memory that every time I open jsfiddle.net, I immediately change to jQuery, but it’s not quite there yet. Not only me, but many people asking for help on freenode have the same problem. About once a day someone posts a jsfiddle link to #jquery asking why something doesn’t work, and the code looks correct, except for the library chosen on the right side.

Until yesterday, I had always assumed that this default was alphabetic. I never paid attention to the fact that M was after D in the alphabet, so Dojo should have been first with jQuery somewhere in the middle. I found out that it’s actually ordered by Piotr’s preference, and he’s actually a MooTools core developer. Also, jsFiddle is actually built on top of MooTools and Django, so it makes sense to keep that as the default.

I just wrote a chrome userscript that can be used to change the default setting to jQuery. This can be easily modified to pick your favorite, or most commonly used library. I wrote it in MooTools out of honor and respect to Piotr, and because I figured it’d be fun to learn some MooTools.

If anyone would like to add a greasemonkey version of this, just let me know and I’ll add it to the gist.