I’ve been spending a fair amount of time playing around with JavaScript these days. As the backbone of the Web 2.0 Ajax technology, homely old JavaScript is finally having its moment in the sun.
Ajax gets all the press, but I think bookmarklets are loveliest little JavaScript tools around. Bookmarklets (also called favelets in deference to Internet Explorer Favorites) are very short JavaScript programs that fit right on the link underneath your mouse click. Click on this link, for example, to see every occurrence of the word “the” on this page turn yellow. (When you get tired of all the yellow, just reload the page.) I adapted this from Jesse Ruderman’s squarefree.com bookmarklets site. Another excellent source of top notch bookmarklets is slayeroffice.com.
I decided to try a little bookmarkletting myself to scratch an itch I had. I write MATLAB code for a living, and one of the MATLAB features I really like is that I can publish directly from code to HTML. Using this technique, you can let the code “tell its own story” as it were. Here is what a published MATLAB program looks like: Building Sundials. I wanted a way to pluck the original source code out of the HTML version of that code, and JavaScript was the way to do it. I wrote a simple little bookmarklet that does the trick. Then my friend Steve Eddins found my quick hack and improved it significantly.
Steve Eddins runs a blog at work called Steve on Image Processing. He’s allowed to do that since he’s a professional image processor. His blog is essentially written in MATLAB and then published to blog format. He has added the new and improved bookmarklet to the bottom of each post so that you can now reconstitute the working code that he started with. Scroll down until you find a link that read “Get the MATLAB code.” It’s a nice way to peek behind the scenes and see a great mind at work.