Kilian Valkhof

Building tools that make developers awesome.

Annoying.js: How to be an asshole

Javascript, 23 May 2011, 2 minute read

In January I came across a website that had a whole slew of JavaScript that attempted to prevent you from selecting text, right clicking or dragging any content onto your desktop. I decided to copy the JavaScript and create a library with examples of JavaScript techniques you can use if you want to scare your visitors away, or want to piss them off. Annoying.js is the result.


The file itself is commented with “functionality”, so I won’t bother repeating it here. You can invoke different functions via the Annoying object: Annoying.noSelect(); will disable text selection, Annoying.noRightClick(); will disable the context menu, and Annoying.kitchensink(); Will turn all the functionality on. But you’re not going to use it anyway, right? ;)

JavaScript is evil!

As you can see, you can do some pretty bad things with JavaScript that will certainly drive your visitors away (or insane!). So why is this kind of functionality available? Some functions is actually very useful if you’re writing complex “html5” web applications. By disabling text-selection on interface elements you can make the application easier to use, and you can re-implement the right click menu using your own options.

Breaking out of iframes is something I think more websites should implement, actually, if only to prevent the “OMG!!!! Look What this Kid did to his School after being Expelled! ” scams that all of my friends on Facebook keep falling for.

Using JavaScript to resize someone’s browser without consent should be reason enough to revoke someone’s license to making websites, though.

Let me know if you have any horrible additions!

Polypane browser for responsive web development and design Hi, I'm Kilian. I make Polypane, the browser for responsive web development and design. If you're reading this site, that's probably interesting to you. Try it out!