Forum Moderators: open

Message Too Old, No Replies

FB Button include script not working

         

milosevic

4:06 pm on Oct 13, 2010 (gmt 0)

10+ Year Member



Hi, I've knocked together a script to mitigate the effects of Facebook's ridiculously bloated like button on page loading times (also loads a twitter button).

The code works, except the Facebook button doesn't appear - but the twitter button does, and it comes after the FB button in the included code. - I'm no JS expert and was wondering if anyone can spot anything.

Here is my JS:

<script type="text/javascript">

// functions when window has loaded
$(window).load(function(){

// define HTML
var socialHtml='<div id="social-footer"><div class="fb"><sc'+'ript src="http://connect.facebook.net/en_US/all.js&#35;xfbml=1"></sc'+'ript><fb:like layout="button_count" action="recommend"></fb:like></div> <div class="twitter"> <a href="http://twitter.com/share" class="twitter-share-button" data-count="none">Tweet</a><sc'+'ript type="text/javascript" src="http://platform.twitter.com/widgets.js"></scr'+'ipt> </div></div>';

// put HTML in the placeholder container
$('#socialPlaceholder').html(socialHtml);

});

</script>

Fotiman

5:04 pm on Oct 13, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Does your code call FB:init somewhere?
[developers.facebook.com...]

Also, the current recommendation by Facebook is to use the iframe version instead of the FBML version.
[developers.facebook.com...]
Note: We do not recommend FBML for new developers. If you aren't already using FBML, you should instead implement your application within an iframe, using the JavaScript SDK and social plugins for client-side integration with Facebook services.

So you might try that instead.

milosevic

8:32 am on Oct 14, 2010 (gmt 0)

10+ Year Member



Hi Fotiman

I'm using this:

[developers.facebook.com...]

Which doesn't mention calling fb:init (and the code worked fine before being I tried to get it to be served by JavaScript). I also believe the iframe recommendation is for app developers rather than the fb like button.

milosevic

9:29 am on Oct 14, 2010 (gmt 0)

10+ Year Member



I've fixed the issue using this

[tobiasz123.wordpress.com...]

To link the FB javascript file rather than using a script tag