Last Updated: February 25, 2016
·
7.314K
· jamesstoddern

Are your "AddThis" buttons slowing you down?

If you have an "Add This" plugin running on your site, the chances are you will notice how it slows everything down. This is particularly the case if you are displaying lots of articles which all have share buttons on them. The reason for this is that the plugin has to make several queries across the web to retrieve the number of "likes" and "shares" etc. so that it can render a digit next to each button (provided you have it configured that way). This all takes time.

The Solution

There is a trick you can use to help increase this performance in most cases, although your site may have other issues which contribute to the speed of your pages loading. Give it a try and you may find it helps.

Firstly, you need to locate your "addthis" script which is embedded in your blog pages, or plugin settings if you are using a blogging framework such as Wordpress. My blog is a bespoke application I wrote, and the embedded scripts for "AddThis" look like this.

<script type="text/javascript"
src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4f3e33c72b9a4e40">

The next thing we need to do is to add a couple of extra parameters which will change the behaviour of the AddThis buttons. The code looks like this:

&async=1&domready=1

This code needs to be added to the script just after the assignment of the "pubid=XXXXX" part, as follows:

<script type="text/javascript"
src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa- 4f3e33c72b9a4e40&async=1&domready=1">

If you were to refresh your page now, you wouldn't see any AddThis buttons - this is because they have been told to wait for the content to be loaded on the webpage first and more importantly, the buttons need to be manually initiated now. Add the following script before the closing tag on your main page.

<script type="text/javascript"> 
 function initAddThis() {
    addthis.init()
 }

initAddThis();
</script>

It should be noted however that this is not a guaranteed fix, as there may actually be other issues on your site which are slowing it down, or at least the appearance of being slow. The very nature of these buttons working asynchronously means that they will load of their own accord, without halting the rest of the elements on your page from loading. So if your AddThis buttons appear later than the rest of your content, then that's good and what we were addressing here.

Hope this has helped...