
Increasing the page load speed of your website has been proven to increase conversion rates (reduce the number of people who get fed up and leave), increase site usage (time on site and pages per visit), and reduce the chance you’ll be taken down by a sudden spike in traffic. WordPress in particular is fairly resource heavy right out of the box so speeding up everything else is a critical piece of running a site on this platform.
But I’m not going to talk about increasing WordPress speed, I want to show you how to improve you page load speed by cutting down on the number of external scripts you’re loading on a particular page. We’re going to do this by hard-coding share buttons into your theme.
Share buttons on your post help your content reach a greater audience by creating easy channels to social networks. By placing a “share on Twitter” button or “post on Facebook” icon, you make it easy for readers to bring the page to their network and increase your traffic.
The problem with most of the share badges out there is that they load a Javascript file from an external source which can take several seconds on a bad day. Depending on where you placed the badge, your content could be held back while the script takes its time and your readers bail.
Javascript calls are an easy way for Facebook and StumbleUpon to put their links on your page but most networks also have a way to share through a URL. Just hand over the link to your page and, in some cases, a title and you’re presented with a simple form to complete and submit. Your content gets to the share site just as it would with the Javascript, sometimes even faster.
All we need to do is display a nice icon and a link to the social network that includes a link back to your page. For my site, I made a few icons using badges I’ve found around the web which you’re welcome to download and use (please don’t link to mine, right-click, save-as, and upload for yourself).
The code for each site is very simple:
Twitter:
<a href=”http://twitter.com/home/?status=[[SHORT TITLE + SHORT LINK]]” title=”Post to Twitter”>
<img src=”[[PATH TO IMAGE]]/twitter-icon.png” alt=”"/>
</a>
Plurk:
<a href=”http://plurk.com/?status=[[TITLE]] [[URL]]” title=”Post to Plurk”>
<img src=”[[PATH TO IMAGE]]/plurk-icon.png” alt=”"/>
</a>
Delicious:
<a href=”http://delicious.com/post?url=[[URL]]&title=[[TITLE]]” title=”Post to Delicious”>
<img src=”[[PATH TO IMAGE]]/delicious-icon.png” alt=”"/>
</a>
Digg:
<a href=”http://digg.com/submit?url=[[URL]]&title=[[TITLE]]” title=”Post to Digg”>
<img src=”[[PATH TO IMAGE]]/digg-icon.png” alt=”"/>
</a>
Facebook:
<a href=”http://www.facebook.com/share.php?u=[[URL]]&t=[[TITLE]]” title=”Post to Facebook”>
<img src=”[[PATH TO IMAGE]]/facebook-icon.png” alt=”"/>
</a>
MySpace (I think this is right but I don’t have a login to test it):
<a href=”http://www.myspace.com/Modules/PostTo/Pages/?l=3&u=[[URL]]&t=[[TITLE]]” title=”Post to MySpace”>
<img src=”[[PATH TO IMAGE]]/myspace-icon.png” alt=”"/>
</a>
Ping.fm:
<a href=”http://ping.fm/ref/?method=microblog&title=[[TITLE]]&link=[[URL]]” title=”Post to Ping.fm”>
<img src=”[[PATH TO IMAGE]]/pingfm-icon.png” alt=”"/>
</a>
StumbleUpon:
<a href=”http://stumbleupon.com/submit?url=[[URL]]&title=[[TITLE]]” title=”Post to StumbleUpon”>
<img src=”[[PATH TO IMAGE]]/stumbleupon-icon.png” alt=”"/>
</a>
LinkedIn:
<a href=”http://www.linkedin.com/shareArticle?mini=true&url=[[URL]]&title=[[TITLE]]&source=[[DOMAIN]]” title=”Share on LinkedIn”>
<img src=”[[PATH TO IMAGE]]/linkedin-icon.png” alt=”" />
</a>
Place these anywhere you’d like on a static page or in the WordPress theme file that controls single posts (typically single.php). You’re about halfway there but the next few steps differ depending on what platform your site uses.
For each page that needs share links, you’ll need to paste the HTML above and replace replace everything with double square brackets with the information from the page.
Now load the page and test that the images appear and that each of the share links takes you to the right place.

What we’re going to do is use built-in WordPress functions to hand over the current URL and title to the links you created above. We need to replace everything with double square brackets above with functions that will automatically add the required info. Make sure to follow the next section if you’re using Twitter.
Sending the URL is simple for sites like Facebook and LinkedIn where the brevity of your message is not an issue but for Twitter we need to save characters where we can. Though a Bit.ly or Tr.im API call could handle shortening the URL for you, I prefer to create one before I post and add it as a custom field. This lets me track click-throughs for Twitter in one place (for me, on the bit.ly site). You’ll need to manually create a shortlink each time but, boo hoo, it takes 30 extra seconds.
First, we need to add a little snippet to grab the short URL and create a short title. After the loop starts…
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
…paste this…
<?php
$key = “shortlink”;
$shortlink = get_post_meta($post->ID, $key, true);
$shorttitle = urlencode(substr(the_title(), 0, 79));
?>
You now have two varibles, $shortlink and $shorttitle, that can be used when creating the HTML for the Twitter share badges. $shortlink is taken from the post (I’ll show you how to add it later) and $shorttitle is a shortened and URL-encoded version of the post title. These come together with your Twitter handle (below) to create a concise, complete Tweet. Now, just replace [[SHORT TITLE + SHORT LINK]] with…
RT%20@joshcanhelp%20<?php echo $shorttitle . ‘%20…%20′ . $shortlink; ?>
… and change “joshcanhelp” to your Twitter handle and you’re ready to go. What we’re doing is creating a tweet with the shortened title and URL that mentions your handle so you get Twitter credit.
When you create a post, you’ll need to create that shortened URL before publishing.

Click add and you’re ready to rock & roll. Now load the single post and test that the images appear and that each of the share links takes you to the right place.
Edit: This was published and enjoyed on Smart Data Collective to the tune of over 600 views and 14 retweets. Some of you might be aware that I’m contracted by the company that manages that site but I have no sway over published content at all, FYI.
Will you follow me on Twitter? You can also subscribe to my posts via RSS here or via email here.
While a great idea, wouldn’t it be better to have them floating so they’re in your line of sight when commenting? I find a blog that has the share buttons around the comments are more likely to receive shares, as it’s a fresh call to action (whereas here, your hard buttons are still up at the top and I’d have to remember that in order to share). Just a thought.
On January 15th, 2010 at 3:37 pm , Josh said...You make a good point but here’s my logic. You always see the top of a post so you’ll always have the chance to see the share links. Not everyone will get all the way to the comments section but everyone will be at the top.
I think this deserves an experiment, though! Adding it to my list… would make a great post, no?
Thanks for the comment!
On January 17th, 2010 at 8:44 pm , Danny Brown said...I can see your logic; but isn’t the point of a blog post to be read all the way through? How’d you know that you like it enough to share if you don’t make it to the end of the post (where the comments generally are)? :)
Look forward to your experiment and see how both options compare. :)
On January 18th, 2010 at 10:03 am , Josh said...The point is to read all the way through but, in reality, I don’t think everyone does. I know I’ve shared articles before I’ve read them thoroughly because of one quick point. This post is a good example. If I don’t have a WordPress site, I won’t read the last half of this. The first part is still relevant but the rest won’t help me.
On January 23rd, 2010 at 7:11 pm , Josh said...OK, Danny, they’re moved.. let’s see what happens! I’ve got Google Analytics plugged in to track each share link and I’ll keep an eye on traffic increases from any one particular network.