Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As I understand you need two things before running some code of yours. These are:</p> <ol> <li>Your page needs to be ready.</li> <li>Facebook API JS is downloaded and initialized.</li> </ol> <p>Unfortunately, I was not able to find an easy way to detect if Facebook API is fully initalized. <em>(Since <code>FB.init</code> is async you can't assume lines bellow it works as init done.)</em></p> <p>As my experiment Facebook functions that have callback and are called after <code>FB.init</code> waits until async <code>FB.init</code> is completed. <em>(Please note that <code>auth.statusChange</code> doesn't fire in some cases.)</em></p> <p>So does something like this work for you? You can use <code>allready</code> event of <code>window</code> for your needs.</p> <pre><code>&lt;script type="text/javascript" src="https://connect.facebook.net/en_US/all.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" charset="utf-8"&gt; window.fbAsyncInit = function() { FB.init({appId: "238797476172233"}); FB.getLoginStatus(function(response) { /* at this point you know that you can use FB API's. */ $().ready(function() { /* at this point you also know that your document is ready. */ $(window).trigger("allready", [response]); }); }); FB.Canvas.setAutoGrow(); }; $(window).bind("allready", function() { /* optionally you can use e and response as function parameters */ alert("now I am sure that both page and FB API's are initialized. I can do anything in this callback!"); }); &lt;/script&gt; </code></pre> <p><strong>JSFiddle</strong>: <a href="http://jsfiddle.net/ubenzer/5y6fF/" rel="nofollow">http://jsfiddle.net/ubenzer/5y6fF/</a> <em>(I added JSFiddle URL to my dummy app's domain but if it doesn't work, check the console and notify me please.)</em></p> <p>Besides these, you don't have any "non-api way" to understand if Facebook is loaded as Ian commented out.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload