jQuery Codes to Fix Facebook Share’s Zero-Count

Facebook share count in "box_count" format shrink to 1/4 of its size if total share-count is zero. This small jQuery code snippets is to fix that "shrinking".

It’s been a long time since Facebook started providing the official share-count. Before that, the void was  filled by a third-party service called fbShare.me, which is still active and works fine.

During one of my performance-optimization experiment, I found that the official Facebook share-count loads much faster. Also, being “official”, it seems a safer choice keeping the future in mind.

But when I switched to new codes, a new problem surfaced as you can see in the screenshot below…

The issue is, if Facebook share count is zero, the big share button shrinks to 1/4 of its size and hides the counter because of the surrounding buttons near it. I prefer the share-count to show even if it was zero.

I really thought that Facebook might have some parameters or setting to fix it, but after a lot of brainstorming, I finally managed to fix it using jQuery codes below:

//fix facebook share's zero-count
    jQuery(".fb_share_no_count .fb_share_count_inner").text("0");

Of course, for the above code to work smoothly, you must have jQuery included somewhere before the above code-snippet.

Here is how it will look like after the fix…

I hope you will find this code useful! 😉

One Comment

Olnac May 2, 2011

I am looking at a way to modify the count in facebook like button.
Could you help me ?

what do I need to do ?