The best way to improve performance is to not copy the pasted code from facebook plugins.
The Facebook Like Button code looks like this:
<div id="fb-root"></div> <script src="http://connect.facebook.net/en_US/all.js#appId=127702313984818&xfbml=1"></script> <fb:like href="example.com" send="true" width="450" show_faces="true" font=""></fb:like>
The problem with this is, if you have 20 buttons like this, then 20 Divs are created with id = "fb-root" and the script for all.js is called 20 times. The best way is to move
<div id="fb-root"></div> <script src="http://connect.facebook.net/en_US/all.js#appId=127702313984818&xfbml=1"></script>
in the page title and whenever you need a similar button, use only
<fb:like href="example.com" send="true" width="450" show_faces="true" font=""></fb:like>
The same goes for facebook comments and other plugins.
In addition, some facebook plugins provide the ability to use xfmbl or iframe code. Always choose iframe code because facebook js needs to parse all xfbml code and convert to iframe. This causes a lot of DOM attachments and slows down the page.
Hope this helps!
source share