Easy Automatic Facebook Share Counts (Fully Javascript)


, ,

Drop this little gem in your site’s header:

function numberFormat(x) {
return x.toString().replace(/B(?=(d{3})+(?!d))/g, ‘,’);

var url = $(this).attr(‘data-url’);
var that = $(this);

$.get(‘http://graph.facebook.com/&#8217; + url, function(data) {

Then, add elements to your page like so:

[html]<div class="trigger_facebook_count" data-url="http://bossip.com"></div>%5B/html%5D

Remember to change the data-url to whatever URL you are referencing, and viola! You’re done.

Leave a Reply