<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Rommel Santor&#039;s Clog &#187; facebook script</title>
	<atom:link href="https://rommelsantor.com/clog/tag/facebook-script/feed/" rel="self" type="application/rss+xml" />
	<link>https://rommelsantor.com/clog</link>
	<description>my exploits and misadventures in programming</description>
	<lastBuildDate>Thu, 04 Feb 2016 12:56:01 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.0.38</generator>
	<item>
		<title>Solution for Facebook Error &#8220;FB.login() called before calling FB.init().&#8221;</title>
		<link>https://rommelsantor.com/clog/2011/02/01/solution-for-facebook-error-fb-login-called-before-calling-fb-init/</link>
		<comments>https://rommelsantor.com/clog/2011/02/01/solution-for-facebook-error-fb-login-called-before-calling-fb-init/#comments</comments>
		<pubDate>Wed, 02 Feb 2011 07:19:40 +0000</pubDate>
		<dc:creator><![CDATA[rommel]]></dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[facebook script]]></category>

		<guid isPermaLink="false">http://rommelsantor.com/clog/?p=131</guid>
		<description><![CDATA[Just thought I&#8217;d share this in case anyone comes googling, as I could not find a satisfactory search result, but was fortunate that it was obvious enough that I realized the issue. I had a page that has had a FB &#8220;like&#8221; button forever with this code: I just finished using a bit of the [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Just thought I&#8217;d share this in case anyone comes googling, as I could not find a satisfactory search result, but was fortunate that it was obvious enough that I realized the issue.</p>
<p>I had a page that has had a FB &#8220;like&#8221; button forever with this code:<br />

<pre class="js:nocontrols:nogutter">
&lt;script src="http://connect.facebook.net/en_US/all.js#xfbml=1"&gt;&lt;/script&gt; 
&lt;fb:like layout="button_count" show_faces="true" width="80" font="verdana"&gt;&lt;/fb:like&gt;
</pre>
<br />
<br/></p>
<p>I just finished using a bit of the new Facebook API to add some Facebook Connect functionality<span id="more-131"></span>, including a &#8220;Login with Facebook&#8221; button in the sidebar of all pages in addition to the Facebook JavaScript SDK asynchronous loader:<br />

<pre class="js:nocontrols:nogutter">
&lt;script type="text/javascript"&gt;// &lt;![CDATA[
  window.fbAsyncInit = function(){
	FB.init({
	  appId   : '...',
	  session : ...,
	  status  : true,
	  cookie  : true,
	  xfbml   : true
	});

	FB.Event.subscribe('auth.login', function(){
	  window.location.reload();
	});
  };
  (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);
  }());
// ]]&gt;&lt;/script&gt;
</pre>
</p>
<p>
<div style="float:left;margin:0 10px 10px 0">
<script type="text/javascript"><!--
google_ad_client = "ca-pub-7639656561235411";
/* Square (250x250) */
google_ad_slot = "8522038794";
google_ad_width = 250;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<br />
Before too much time passed, I discovered that on just some pages, one or both of these things would occur:</p>
<ol>
<li>Trying to click on the &#8220;Login with Facebook&#8221; button would do nothing but result in this JS console error: &#8220;FB.login() called before calling FB.init().&#8221;</li>
<li>The page would just keep reloading itself.</li>
</ol>
<p><br/><br />
You may have guessed just by looking at the above code what the cause of the problem is. The pre-existing &#8220;like&#8221; button code is loading the all.js script synchronously, but the Facebook Connect code is also loading the same file, but asynchronously. The fix is even more obvious: Remove the old &lt;script&gt; tag that is paired with the like button. Et voila, fin.</p>
]]></content:encoded>
			<wfw:commentRss>https://rommelsantor.com/clog/2011/02/01/solution-for-facebook-error-fb-login-called-before-calling-fb-init/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
