Initializing and Loading Facebook Connect Features
From Facebook Developer Wiki
After referencing the script FeatureLoader.js.php in your site, the only functions you can call immediately are those functions in the FB.Bootstrap class and its alias functions.
To use other API functions, you need to make sure the corresponding features are loaded.
In most cases, your site would call FB.init() to initialize the Facebook API first. By default, FB.init() would start loading the XFBML feature and all its dependencies. In addition, you can use FB.ensureInit() to make sure the API functions you are about to call are ready and loaded. For example:
It is important to note that features are not guaranteed to be available immediately after calling FB.init() because FB.init() triggers an asynchronous loading of required scripts. You need to use FB.ensureInit(callback) to ensure that the features are loaded when the callback function is invoked.
If you are not calling FB.init() and want to ensure that the features you need are loaded, you can call FB.Bootstrap.requireFeatures(). Here is an example of the code that uses this approach to perform the same work:
Note: You can call FB.Bootstrap.requireFeatures() multiple times. If the required features are already loaded, the callback function will be invoked immediately.
[edit] See Also
- FB_RequireFeatures: for the list of features you can load with the library.
- FB.Connect.showPermissionDialog
- FB.Facebook.Init
- Cross Domain Communication Channel
