Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect when Facebook Like Button is loaded

As you probably know the Facebook Like button loads very slowly.

And I am trying to figure out how to detect when the button has finished loading and has been added to the website.

The reason being that I show a loading animation, and then hide that and show the button, but I'd like to show the button when it has finished loading.

Can this be done?

Thanks in advance everyone!

like image 795
Cristian Avatar asked Jun 29 '12 13:06

Cristian


People also ask

When was the Like button added to Facebook?

The like button is a feature of social networking service Facebook, where users can like content such as status updates, comments, photos and videos, links shared by friends, and advertisements. The feature was activated February 9, 2009.

What was the result of Facebook adding a like button?

In 2009, Facebook introduced the Like button. The tiny thumbs-up symbol, a simple indicator of people's preferences, became one of the social network's most important features. The company allowed other websites to adopt the Like button so users could share their interests back to their Facebook profiles.

How do I make my like button visible on Facebook?

Go to Settings › General, then click the Share tab. Enable the Facebook Like/Recommend button setting by clicking the “thumb up” Like icon. Then click the settings (...) icon in the upper left of the button.

Why did the like button disappeared on Facebook?

Facebook announced it is “removing 'Likes' and focusing on 'Followers' to simplify the way people connect with their favorite Pages.


1 Answers

One can subscribe to the xfbml.render event to get notified when rendering is complete, which only fires once per page parsing (and works not only for xfbml, but for the new html5 trickery too). Page parsing automatically happens when the FB JS SDK loads if xfbml : true.

window.fbAsyncInit = function() {
  FB.init({
    ...
    xfbml : true
  });

  FB.Event.subscribe('xfbml.render', function(response) {
      alert('OMG... All Facebook sociaal plugins on page rendereed.... finally!');
  });
};

// And load the SDK Asynchronously here
like image 77
Tarnay Kálmán Avatar answered Sep 23 '22 23:09

Tarnay Kálmán