I have always used WordPress plug-ins to setup social media sharing links, but what I don’t love about plug-ins is that you really don’t know what sort of code is being injected into your WordPress installation. If you are curious, add a few plug-ins and View the Source of your webpage, more times than not the head gets filled with JS includes and messy code. Call me a code freak, but I strive for cleanliness.
Get the code:
The code is really easy to implement, first you need to grab to code from each of the links below.
Code to implement
Using the permalink and title WordPress functions, you can easily integrate the post URL’s into the button code provided above. You can place the following code on your index or single post page templates, just make sure its placed within the posts loop otherwise it will not be able to pull the permalink or title.
<script src="http://connect.facebook.net/en_US/all.js#appId=204703199589477&xfbml=1"></script><fb:like href="<?php the_permalink() ?>" send="false" width="90" show_faces="false" action="like" font="" layout="button_count"></fb:like>
<g:plusone size="medium" href="<?php the_permalink() ?>"></g:plusone>
<!– Place this render call where appropriate –>
po.src = ‘https://apis.google.com/js/plusone.js’;
var s = document.getElementsByTagName(‘script’); s.parentNode.insertBefore(po, s);
Facebook like adds 415k JS overhead to the page.
Twitter Tweet adds 20k JS overhead to the page.
Google +1 like adds 178k JS overhead to the page.
I will be investigating how to get these JS includes either down in size or to load asynchronously, therefore not affecting the load of the page.