On a few websites that I maintain, I noticed that adding a share button like AddThis to a page varyingly slows down page loading, sometimes significantly.
What is the explanation for this and what can be done to keep share buttons while not incurring page loading performance penalty for this?
add the script call to the bottom of your page, that's what i do, right on top of </body>
.
...
all my html
...
<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style ">
<a href="http://www.addthis.com/bookmark.php?v=250&username=xa-4d4c6a9028bcda9b" class="addthis_button_compact">Share</a>
<span class="addthis_separator">|</span>
<a class="addthis_button_preferred_1"></a>
<a class="addthis_button_preferred_2"></a>
<a class="addthis_button_preferred_3"></a>
<a class="addthis_button_preferred_4"></a>
</div>
<!-- AddThis Button END -->
...
all my html
...
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d4c6a9028bcda9b"></script>
</body>
</html>
Edit: By moving the script call to the bottom of the page your page will load before the script and your users will not feel the impact.
@Anodroid - I would leave your PHP at the top.. PHP scripts will be dependant on the processing speed of your server and the javascript will be determined first on the connection speed to the host "http://www.addthis.com/bookmark.php?v=250&username=xa-4d4c6a9028bcda9b" and how fast they can server the content to be embedded on page "| "
good luck