Easy Automatic Facebook Share Counts (Fully Javascript)

Drop this little gem in your site’s header: [javascript] <script> function numberFormat(x) { return x.toString().replace(/B(?=(d{3})+(?!d))/g, ‘,’); } jQuery(document).ready(function($){ $(‘.trigger_facebook_count’).each(function(){ var url = $(this).attr(‘data-url’); var that = $(this); $.get(‘http://graph.facebook.com/&#8217; + url, function(data) { that.html(numberFormat(data.shares)); }); }); }); </script> [/javascript] 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 toContinue reading “Easy Automatic Facebook Share Counts (Fully Javascript)”