Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I have a website with a number of pages that sport Twitter, Facebook and Reddit share buttons. They take forever to load and until they do the rest of the page doesn't load. So how I can make them load last?

Currently, they are loaded something like this:

<div class="item"><a href="http://twitter.com/share" class="twitter-share-button" data-count="vertical" data-via="FridgeToFood" data-related="danielBingham:Recipe and update tweets from Fridge to Food.">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div>
<div class="item"><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like layout="box_count" width="40"></fb:like></div>
<div class="item">
    <script type="text/javascript">reddit_target='recipes';</script>
    <script type="text/javascript" src="http://reddit.com/static/button/button2.js"></script>
</div>

They are in a <div> called "shareWrapper" and are loading to one side of the page. The buttons load where ever the script code is placed. As far as I know, I can't place the script code at the bottom of the page and move the resulting buttons after the fact. I want them to appear near the top, which right now means they are stopping everything below them from loading for several seconds.

I tried loading them using JavaScript, but using jQuery's $(document).ready(), but that failed. It seems to leave the page in some sort of loading loop from which it never emerges. Are there other ways to get these to load last?

share|improve this question

2 Answers 2

I suggest to read this article by Frederic Towsend, the author of the W3 Cache Plugin for WordPress: http://www.w3-edge.com/weblog/2011/02/optimize-social-media-button-performance/.

share|improve this answer

If your social sharing widget is fixed to the edge of the page, you can simply move the code for this to the footer (or just above). They then won't get loaded until everything else above the footer has already loaded which I believe is what you're wanting to know.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.