Mobile app version of vmapp.org
Login or Join
Kevin317

: How can I make Twitter, Facebook and Reddit share buttons load last? I have a website with a number of pages that sport Twitter, Facebook and Reddit share buttons. They take forever to load

@Kevin317

Posted in: #Javascript #Jquery #SocialMedia

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?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Kevin317

2 Comments

Sorted by latest first Latest Oldest Best

 

@Jessie594

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.

10% popularity Vote Up Vote Down


 

@Goswami781

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

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme