On my wordpress website I have a lot of facebook interactions like og.watch, fb.login and others. For example I use:
http://w.sharethis.com/button/buttons.js
for some buttons and this js include all.js from facebook. This is in head.
Again in head I have:
<script type="text/javascript">
window.fbAsyncInit = function(){
FB.init({
appId: xxxxxxxxxx,
status:true,
cookie:true,
xfbml:true,
oauth:true
});
};
</script>
<div id="fb-root"></div>
<script type="text/javascript">
// Load the SDK Asynchronously
(function(d){
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/ro_RO/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
</script>
And in footer I have fb-like-popup.js from a plugin witch use fb.edge to verify a like button.
The main problem is that sometimes I get in the console errors like: Fb.init not defined in fb-like-popup.js and when I have this error in the page I cannot use the facebook features from my page.
Question 1: Why do I get in different files fb.init not defined while I have the fb.init in the head of page?
Question 2: Is there a method to define facebook once for all my site pages?