FB RequireFeatures
From Facebook Developer Wiki
FB_RequireFeatures is a method for dynamically loading JavaScript components. It is defined in FeatureLoader.js.php.
Contents |
[edit] Usage
In most Facebook Connect sites, you won't need to call RequireFeatures at all; it will be called for you within this API call:
However, if you are particularly performance-sensitive, or you are using Facebook Connect on only a small part of your site (for example, just to display a Feed form), then you may want to only load the Facebook JavaScript libraries at the time you need them.
You will always write a script include for FeatureLoader.js.php within your main page. This file is small and shouldn't affect your latency.
Then, when the time comes to actually make use of the Facebook functionality, you can wrap your functions in FB_RequireFeatures. This loads the necessary libraries, and then executes your function. You will also need to call FB.init once the libraries are loaded.
For instance, this code could be used as an onclick handler for a Facebook Connect login button:
You can also use this to raise a Feed form:
[edit] Features
Here are all the features you can use with FB_RequireFeatures. Items in black are the most commonly used.
[edit] Feature Definitions
The Facebook Connect JavaScript Library comprises a list of features. The available features include:
- Api
- Allows for making API calls to Facebook from JavaScript.
- Base
- Basic core functions, like bootloads
- CanvasUtil (dependencies => "Common", "XdComm")
- Displays inline iframe lightboxes, including Feed forms. Supports dynamic resizing of iframes and other utilities specific to iframe-based Facebook applications.
- Common (dependencies => "Base")
- Code common to all features, utility functions
- Connect (dependencies => "CanvasUtil", "Api")
- Allows for all Facebook Connect login functionality.
- XdComm (dependencies => "Base", "Common")
- Cross-domain communications library; allows for cross domain communication.
- XFBML (dependencies" => "CanvasUtil", "Api", "Connect")
- XFBML support (all classes in FB.XFBML namespace); this feature depends on Facebook Connect, and also allows for drawing of XFBML elements.

