Help with Several Facebook like buttons on one page
I have created a page where there are various items on a page and people need to vote on them by clicking "recommend" (like how they have it on levi.store.com). The items are sorted based on the number of "recommends" they receive. The problem I am having is that there are 100 of these items, and when I try to display them it becomes way too slow. Is there a way to do this more effectively, this is some pseudo-code of what I have (I am using Wordpress)
$theCategory = 'the-item-category'; //every item is a post and is placed into this category
$items->query('cat='.$theCategory); //this gets all those items in that category
while($items->have_posts()) : $items->the_post();
<h1><?php the_title(); ?></h1>
<iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink($post->ID)); ?>&layout=button_count&show_faces=false&width=450&action=recommend&font&colorscheme=light&height=21" scrolling="no" frameborder="0" st开发者_StackOverflowyle="border:none; overflow:hidden; width:140px; height:21px;" allowTransparency="true"></iframe>
I would recommend using the FBML version of the Like button. You can then display them on-demand, like TechCrunch does on story mouse over, or start loading them after page load (i.e. on DOM ready). Turn off automatic FBML parsing in your Facebook init and them use FB.XFBML.parse(DOM ID) to render each Like button.
Using iframes directly mean you are trying to load 100 web pages on page load. That's a lot, especially when browsers will only open a max of 8 connections per domain. Some open less. So with 100 Like buttons, it will take over a dozen "rounds" to load everything.
I'm assuming you are fetching and caching the number of Likes each story has on the server.
精彩评论