JavaScript DiggBar killer (but not blocker)


Digg came up with the “DiggBar”, a frame that keeps visitors on the domain while framing the destination website below it.


This event caused massive controversy and anger, and has led to the creation of many “DiggBar killer” plugins / script includes for a huge variety of website systems. See today’s Daring Fireball linked list for a good sample. A lot has been said, but Gruber summed up some of the main problems with the DiggBar with:

Framing breaks bookmarking, it breaks copy-and-paste from the location field, it breaks your browser history, it breaks bookmarklets. There’s nothing OK about it.


I personally don’t really care to block visitors coming from Digg — I’ve already killed comments here and moved them to Twitter anyway — but I do care about the problems inherent to “being framed” on my own domain. Now, I could’ve joined the masses and put the WordPress DiggBar killer plugin in place, but what I really want is for the DiggBar to just die a horrible death, not unlike the failed Facebook Terms of Service from a few months ago that were an equally poorly thought-through mistake.

The frame killer that Gruber linked to at the bottom of his How to Block the DiggBar post, however, also kills frames that are a little more reasonable, such as Google Images’ frame. I didn’t want to be that zealous in my effort, so I’ve adjusted it slightly to make it pretty much just kill the DiggBar and direct the visitor straight to my own site, no frames or other nonsense, without having it effect other implementations of frames that aren’t as problematic.

So, for those who want to do the same and simply kill the DiggBar and put those visitors directly to your content, no blocking, no messaging, no other stuff… just add these three lines of Javascript to the top of your page somewhere inside script blocks, or include it in whatever JS file include you have:

if (top !== self && document.referrer.match(/{1,8}/)) {


That will just kill the DiggBar and restore Balance to the Force. You know, like the Internet was before the DiggBar came around.


  1. See the Digg page for this article or just click this DiggBar link:, to see how my JavaScript solution just puts you straight back to this site.
  2. Ethan Marcotte had a great suggestion for a tiny improvement: using top.location.replace()instead of top.location.href prevents the Back button being broken (i.e. you’d have to hit the Back button twice with the old method, not with location.replace()).
  3. I’ve written down some additional thoughts to all of this that might be worth reading, too.

If you liked this, you should follow me on Twitter!