How to Add a Reddit Button to Your Site

by jim on February 15th, 2010

As your site grows, the likelihood that it gets submitted to a social news site like Reddit also grows. When that happens, you’ll want to get it as many upvotes as possible so that it can become more popular. The best way to do that is leverage your existing visitors, hoping they will have Reddit accounts and having them give you the votes to put you over the top. It’s as simple as putting in this snippet of code to your page.

<script type="text/javascript" src="http://www.reddit.com/button.js?t=1"></script>

The cost of putting a button like this on a page is that it’s an extra javascript call to an external server. While the cost may seem minimal, it’s enough that you probably don’t want to put this type of button on every post in the hopes that someone clicks on it. If you just want a standard static reddit button, you can do this instead:

<a href="http://www.reddit.com/submit" onclick="window.location = 'http://www.reddit.com/submit?url=' + encodeURIComponent(window.location); return false"> <img src="http://www.reddit.com/static/spreddit7.gif" alt="submit to reddit" border="0" /> </a></script>

It’ll put something like this:
submit to reddit

If you want to make it a bit faster, download the image and store it locally.

RSS Subscribe Like this article? Get all the latest articles sent to your email for free every day. Just click "Subscribe" and enter your email. Your email will only be used for this daily subscription and you can unsubscribe anytime.

Leave a Reply