Skip to content

Instantly share code, notes, and snippets.

@dalethedeveloper
dalethedeveloper / gist:965036
Created May 10, 2011 18:18
Wordpress + Facebook Done Right: Load FBConnect asynchronously for XFBML and handle the channelUrl
/**
* A class-based approach to bring in Facbook Connect asynchronously on every
* frontend page load. Also handles side-loading channelURL when using
* Facebook's FB.init() method.
*
* This fits nicely in any functions.php, or can be dropped in to a standalone
* php file to use as a plugin.
*
* @link http://developers.facebook.com/docs/reference/javascript/FB.init/
*/
/**
* Works in Chrome, Firefox, MSIE, Opera and Safari.
*/
function onDOMContentLoaded( event ) {
if( event ) {
document.removeEventListener( event.type, onDOMContentLoaded, false );
}
document.onreadystatechange = null;
// For testing purposes.
alert( "DOM Content Loaded" );