How to download javascript facebook api SYNCHRONOUS ...?

I want to download facebook api (javascript SDK) synchronously. I saw this code from facebook developers.

<div id="fb-root"></div> <script src="//connect.facebook.net/en_US/all.js"></script> <script> FB.init({ appId : 'YOUR_APP_ID', channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File status : true, // check login status cookie : true, // enable cookies to allow the server to access the session xfbml : true // parse XFBML }); </script> 

as well as a link to another link http://www.masteringapi.com/tutorials/facebook-javascript-sdk-best-practices/58/ it is mentioned that "But you need to make sure that you do not define FB in your own JS- code or libraries! "...............

I'm confused....! Please help me....

+6
source share
2 answers

What you do looks great.

The instruction you saw: "But you need to make sure that you do not define FB in your own JS code or libraries!" this is just a warning not to declare a variable named FB in your application, otherwise you will hide the SDK for Facebook.

In your code on the very next line, you can start calling using FB.api or any other method.

Does it help?

+3
source

Add the code below after opening the html tag

  <div id="fb-root"> </div> <script> window.fbAsyncInit = function() { FB.init({ appId: 'Your APP ID', status: true, // check login status cookie: true, // enable cookies to allow server to access session xfbml: true, // parse XFBML oauth: true }); }; (function() { var e = document.createElement('script'); e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; e.async = true; document.getElementById('fb-root').appendChild(e); } ()); </script> 

This code will load the javascript SDK asynchronously.

-8
source

Source: https://habr.com/ru/post/907824/


All Articles