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/' + url, function(data) {

Then, add elements to your page like so:

<div class="trigger_facebook_count" data-url="http://bossip.com"></div>

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

Leave a Reply

%d bloggers like this: