I recently ran into a problem when the Facebook API takes a very long time to initialize when there are a lot of images on the page. I would have been more noticeable when there were about 50 MB of images. Facebook init is actually called first in front of everything, but it still seems to be waiting for all images to be loaded first. 95% of the images are actually added to the page asynchronously.
Does anyone encounter a similar problem? At the moment, I'm not sure if this is a bug or how browsers behave, but it is pretty consistent between Chrome and Safari. I also made sure that there is no synchronous code anywhere that could block initialization.
Since we rely on Facebook to find out if the user has already been logged in by first checking the cookie (or making a call to Facebook if there is no cookie), this affects the user interface a bit. We also use Facebook login as the main way, so the user cannot log in until the API is initialized.
This is very easy to play with a slow internet connection. If you want to see the actual behavior, you can go to https://www.toovia.com . Click on the login in the upper right corner and you will see that Face Pile does not exist, that is, the API is still initializing.
This is how I initialize the API. It is largely copied from the Facebook documentation.
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0]; if (d.getElementById(id)) {return;} js = d.createElement('script'); js.id = id; js.async = true; js.src = "//connect.facebook.net/en_US/all.js"; ref.parentNode.insertBefore(js, ref);
source share