title: Uncaught ReferenceError: FB is not defined when using FB.getLoginStatus
body: <p>I'm trying to check if a user has logged in using facebook and get that error in JS console. My code looks like this:</p>
  
  <pre><code>&lt;div id="fb-root"&gt;&lt;/div&gt;
  &lt;script&gt;
      window.fbAsyncInit = function () {
          FB.init({
              appId: '######', // App ID
              status: true, // check login status
              cookie: true, // enable cookies to allow the server to access the session
              xfbml: true  // parse XFBML
          });
      };
  
      // Load the SDK Asynchronously
      (function (d) {
          var js, id = 'facebook-jssdk'; if (d.getElementById(id)) { return; }
          js = d.createElement('script'); js.id = id; js.async = true;
          js.src = "//connect.facebook.net/en_US/all.js";
          d.getElementsByTagName('head')[0].appendChild(js);
      }(document));
  
      FB.getLoginStatus(function (response) {
          if (response.status === 'connected') {
              // the user is logged in and has authenticated your
              // app, and response.authResponse supplies
              // the user's ID, a valid access token, a signed
              // request, and the time the access token
              // and signed request each expire
              var uid = response.authResponse.userID;
              var accessToken = response.authResponse.accessToken;
          } else if (response.status === 'not_authorized') {
              // the user is logged in to Facebook,
              // but has not authenticated your app
          } else {
              // the user isn't logged in to Facebook.
          }
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>What could be the problem and are there any sugestions on how to fix it?</p>