如何让 facebook 之类的按钮更快?
在我的网站中,对于每个博客条目,我都有一个类似 facebook 的按钮。所以在索引上,有多个(目前超过10个)类似的按钮。
这些类似的按钮使我的页面使用起来有点麻烦。总页面时间变成几秒钟,并且在加载时出现滞后/跳跃(即使所有内容都已加载)。除了不在索引上显示“喜欢”按钮之外,还有其他方法可以解决此问题吗? (页面上的单个“赞”按钮产生的延迟可以忽略不计)
作为参考,我的网站位于 http://lastyearswishes.com在firebug中,您可以看到页面加载时间为20秒,其中大约200毫秒与我的实际网站相关。每个 Facebook Like 按钮似乎都会执行三个独立的不可缓存的独特请求。
事后思考:现在(近两年后)我决定放弃 Facebook。即使使用异步代码,它仍然会导致页面渲染时间明显延迟。它还使用了一些奇怪的 JavaScript,搞乱了我的布局。当放入 Twitter 按钮时,我的布局立即看起来应该是这样的(Facebook 所做的具有对齐和浮动功能的东西。我永远无法使用边距或任何东西来让 Facebook 按照我想要的方式排列)
in my website, for each blog entry I have a facebook like button. So on the index, there is multiple(more than 10 at the moment) like buttons.
These like buttons make my page a bit cumbersome to use. The total page time becomes several seconds and it's laggy/jumpy while loading(even though all the content is loaded) while it's loading. Is there anyway to fix this other than not showing the like button on the index? (a single like button on a page produces negligible lag)
For reference, my website is at http://lastyearswishes.com In firebug, you can see that the page load time is 20 seconds, of which about 200 milliseconds is tied back to my actual website. Each facebook like button appears to do three separate non-cacheable, unique requests.
Afterthought: Now (nearly 2 years later) I decided to give up on facebook. Even with asynchronous code it still enduced a noticable delay in page rendering time. It also uses some stange javascript that screws up my layout. When dropping in twitter buttons, my layout looked immediately the way it should (something with alignment and float that facebook did. I could never use margin or anything to get facebook to line up like I wanted)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Facebook Developers 提供了用于创建异步点赞按钮的 JavaScript
:异步加载 SDK
此处:
更新:
尝试一下这部分(并且在 URL 末尾添加
#xfbml=1
,应该与您网站上的结果相同,但异步加载):将此脚本放在页面底部
Facebook Developers provides the javascript to create an asynchronous Like button
found here: Loading the SDK Asynchronously
c/p'd here:
Updated:
Try just this portion (and add
#xfbml=1
at the end of the URL, should be the same result on your site but async loading):Put this script at the bottom of your page