HOW-TO: Make an AJAXified Digg-It button (with bonus RSS subscription!)
I made a little widget for my blog that supports both bookmarking (to popular bookmarking sites like Digg) and subscribing to my site (via popular RSS readers like BlogLines). The widget uses a little javascript to hide the (hideously tacky) icons of the various sites until the user clicks on it. Check out the top right corner of my blog, or the bottom of this article, for a demo.

The cool things about this widget are:
1) It is much less ugly and distracting than current solutions (which embed a gaudy list of icons into your blog).
2) It is independent on any server-side environment: because it's all in javascript, it can run in WordPress, Moveable Type, Drupal, or any other blogging engine or CMS. In fact, it can run in any web page at all.
3) It frames RSS subscription in language the user can understand (e.g. "Add this to Bloglines", rather than "XML").

(update: for those playing along at home, you can download the javascript here, css here and here, and the html here
The usability of the typical blog approach to RSS (directly linking to XML feeds) is very low, as Peter Merholtz , Jeffry Veen, James Bennett, and Keith Robinson have all noted.
The problem is that users don't know what RSS or XML is, and certainly don't want to look at XML code. The answer to the RSS usability riddle is that subscription needs to be framed in terms of the tool the user is subscribing with. "Add this to Bloglines" makes much more sense to the average reader than "XML" or "RSS".
Unfortunately, as RSS readers proliferate, this means that more and more links need to be added to your site ("Add this to MyYahoo,", "Add this to MSN", etc). My widget solves this problem by hiding the links until they are needed.
The code was easy as pie to write. Below is a brief explanation of how I did it, with relevant code snippets.
1) Hiding and revealing the widget (which is wrapped in a Span) is accomplished by simply setting el.style.display to "none" for the Span that holds the widget.
//html code
onClick="switchMenu('subscribeit_menu');"
//javascript code
function switchMenu(obj) {
var el = document.getElementById(obj);
if ( el.style.display != "none" ) {
el.style.display = 'none';
}
else {
el.style.display = '';
}
}
2) Links to the various bookmarking and RSS subscribing sites are provided by assigning to "javascript:location.href", like so
href="javascript:location.href='http://del.icio.us/post?v=2&url='+_getURL()+'&title='+_getTitle()+' '"
3) The URL of the current page is extracted using window.location.href, like so :
function _getURL(){
return encodeURIComponent(window.location.href);
}
4) Future planned improvements include removing the ugly hardcoding of the site url in the javascript
function _getRootURL(){
//TODO: use window.location.hostname, host, or SOMETHING!!!
return 'http://www.jonathanboutelle.com'
} .
In general, there's no rocket science here, and it only took a couple of hours to code. These kinds of quick tactical improvements to existing sites are where JavaScript really kicks ass!