Hiding email addresses from bots
Bots have been scraping email addresses on the Internet for many years now. And since spam is still very much a problem these days, it was time I started obfuscating my address.
The compromise
Obfuscating an address from bots is a compromise between security and user experience.
After looking for a while on StackExchange and other places, it seems like the best way to do it is:
Use Javascript to make a mailto link, which is now well supported in browsers and creates the best experience while remaining unprocessed by bots, since very few enable Javascript.
Keep an image backup for users without Javascript.
Implementation
First, generate the image, preferably locally. I prefer not to rely on image generators. MS Paint (or KolourPaint under Linux) do a great job and you don’t risk providing your address to yet another database. Then place it in your link.
Then, give your link div an id
and place something like this next to your link:
1 | <script> |
That way even bots that skim over the Javascript file will have trouble making sense of this.