title: Facebook Javascript SDK error "Object [object Object] has no method 'init`
body: <p>One of the first things that needs to be done in order to load the SDK for interacting with Facebook, is to run:</p>
  
  <p><code>FB.init(params)</code></p>
  
  <blockquote>
    <p>This method is used to initialize and setup the SDK. . . . . .
    All other SDK methods must be called after this one, because they
    won't exist until you do.</p>
  </blockquote>
  
  <p><a href="https://developers.facebook.com/docs/javascript/reference/FB.init/" rel="nofollow">Facebook JavaScript SDK: .init()</a></p>
  
  <p>I'm getting the error msg:</p>
  
  <p><code>Object [object Object] has no method "init"</code></p>
  
  <p>I'm not getting an error that <code>FB</code> is undefined, so I'm assuming that at least part of the <code>Facebook Javascript SDK</code> loaded.</p>
  
  <p>When the <code>SDK</code> loads, Facebook puts contents into a <code>&lt;div&gt;</code> element:  <code>&lt;div id="fb-root"&gt;&lt;/div&gt;</code></p>
  
  <p>Just for the fun of it, I used <code>.innerHTML</code> to see if I could extract anything out of that <code>&lt;div&gt;</code>.</p>
  
  <pre><code>var fbRootContent = document.getElementById('fb-root').innerHTML;
  console.log("fbRoot Content: " + fbRootContent);
  </code></pre>
  
  <p>And it does show that something got injected into that <code>&lt;div&gt;</code>.  So, . . . I'm assuming that at least some of the <code>Facebook Javascript SDK</code> loaded.</p>
  
  <p>One possible issue, is that I'm using Google Apps Script, and lots of content gets sanitized and stripped out before it is served.  So it's a possibility that, even though some of the SDK is loading, some of it is getting stripped out by the sanitation process.</p>
  
  <p>I'm simply trying to determine if it's possible to load the <code>Facebook Javascript SDK</code> into Apps Script.  I haven't had any luck so far.  Here is the latest code I've used in the attempt to test whether the SDK can be loaded or not.</p>
  
  <pre><code>&lt;div id="fb-root"&gt;&lt;/div&gt;
  &lt;label id="lblToHid"&gt;Load Facebook Javascript SDK&lt;/label&gt;
  
  &lt;br&gt;
  &lt;br&gt;
  &lt;button id="btnTest"&gt;test&lt;/button&gt;
  
  &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://connect.facebook.net/en_US/all.js"&gt;&lt;/script&gt;
  
  &lt;script&gt;
  $(document).ready(function() {
  $("#lblToHid").hide();
    $("#btnTest").click(function(){
    $("#lblToHid").show();
  });
  
  callFB();
  fbAsyncInit();
  
  });
  
  function callFB(){
    console.log("callFB ran: ");
      window.fbAsyncInit = function() {
        console.log("AsyncInit ran");
  
    console.log("Here is the object FB: " + FB);
  
    var fbRootContent = document.getElementById('fb-root').innerHTML;
    console.log("fbRoot Content: " + fbRootContent);
  
      FB.init({
          appId      : 'myAppID Here',
          status     : true, // check login status
          cookie     : true, // enable cookies to allow the server to access the session
          oauth      : true, // enable OAuth 2.0
          xfbml      : true  // parse XFBML
        });
  
    console.log("callFB done running: ");
  
    };
  };
  &lt;/script&gt;
  </code></pre>
  
  <p>Note that I am not loading the SDK asynchronously.  I'm doing that on purpose to test if it will load or not.  Note the line:</p>
  
  <pre><code>&lt;script src="https://connect.facebook.net/en_US/all.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>Facebook suggests loading the SDK a different way.  Why?  Because it might slow down the initial load of your app.</p>
  
  <p>So, why am I getting the error: <code>Object [object Object] has no method "init"</code></p>
  
  <p>And is it possible to load the <code>Facebook Javascript SDK</code> into Google Apps Script?</p>
  
  <p>I'm using jQuery: <code>$(document).ready</code>, </p>
  
  <p><a href="http://learn.jquery.com/using-jquery-core/document-ready/" rel="nofollow">jQuery $(document).ready()</a></p>
  
  <p>so <code>FB.init</code> shouldn't be getting called until the <code>&lt;script&gt;</code> tag has loaded the Facebook SDK.</p>