Addtoany slow loading

24th of June 2010 3

Addtoany slow loading

When working with a clients site i wanted to the sharing script from AddToAny, i however noticed that the inclusion of their javascript bogged the whole site down and caused extreme delays (3+ seconds).

addtoany slow loading

This wasn't acceptable at all so i had to come up with a proper solution which was quite simple with some jQuery and ajax:

<script type="text/javascript">
$(window).load(function() { $.ajax({ url: 'http://static.addtoany.com/menu/page.js', dataType: 'script' }); });
</script>

We simply dump the code we get from AddToAny and replace the call to their servers with the jQuery ajax scripts that loads "onload". This efficiently kills all slow load delays and the only drawback is that your AddToAny-button(s) only will work when a page has finished loading.

Share it!

Was it good for you to?

Sponsors

Support for the site!


3 great comment(s) for this post

  1. blogjunkie 3:47 am 1/10 of 2010

    I’m a total jQuery noob, but isn’t getScript() better for this?

    http://api.jquery.com/jQuery.getScript/

    Reply
  2. Joe 9:20 pm 17/12 of 2010

    Okay, I did further research on share buttons and deciding I really wanted to stick with AddToAny if there were any way to work it out. As far as I can tell, it has the biggest list of networks/options and none of the other share buttons categorize emailing, bookmarks and sharing separately AND have a search field (let alone the pop-up feature one of my clients wanted. So I confirmed what futta’s blog (see my last comment) says about Media6Degrees.com tracking the activity of users of the AddToAny button (it’s true, you can see it in AddToAny’s page.js). Apparently, this is what slows down the load time. As mentioned in futta’s blog comments, AddToAny has added an opt-out parameter to their API (no_3p = true). Once I used this on one of my clients websites, the load time of the AddToAny button went from about 3 seconds to 125 milliseconds.

    So the only thing I might need to figure out in the future is how to get it to wait until the page finishes loading to then load page.js. Actually, the only reason I have any concern on that is because addtoany.com recently went into a spell of loading way to slowly, which then affected my client’s site. Perhaps with the tracking turned off, I may not need to worry about this anymore, so I’m only going to continue to keep an eye on it for now.

    But this raises a question about your code, since it is designed to achieve that end, and because it didn’t work for me. Did it actually work for you upon trial?

    Reply
  3. Level 5 (of 10) Watch out, this user is an admin! His job is to make everything on this site work well - don't mess with him!

    Tommie Hansen (16 comments) 1:17 am 18/12 of 2010

    @Joe: Yes, however my code now is quite old and i have been in contact with them before so my code Might not work.

    However i use the code here and it do work, i have no idea of it achieves the disired effect simply because i’m swamped with work and haven’t had time to re-check things unfortunately. :/

    If you got propblem, just check this pages sourcecode. :)

    Reply

Your opinion matters. Add it below.


Tip: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • Popular posts this month
  • 5 Random posts
  • Crossbrowser text shadow with jQuery When working with a clients site i wanted to the sharing script from AddToAny, i however noticed that the inclusion ...
  • Simple CSS buttons When working with a clients site i wanted to the sharing script from AddToAny, i however noticed that the inclusion ...
  • Simple CSS menu When working with a clients site i wanted to the sharing script from AddToAny, i however noticed that the inclusion ...
  • jQuery show / hide anything When working with a clients site i wanted to the sharing script from AddToAny, i however noticed that the inclusion ...
  • CSS3 = Fail When working with a clients site i wanted to the sharing script from AddToAny, i however noticed that the inclusion ...

Follow me @design_byme RSS Design Feed

Copyright Tommie Hansen since 2010. All rights reserved. Design and the Absolute Theme by Tommie Hansen.