How do I add social bookmarking icons to my site that only load or look for javascript only when executed? I have taken a look at the Sharethis and Addthis modules. I have also looked at putting the embed codes directly from twitter and facebook in my site. With each option, my site needs to load the external javasript libraries/images from the third parties on every page load. This doubles(and in some cases, triples) my load times. It can also go sideways if the external site is under a heavy load or offline. It appears there is no way to provide a local copy of the js files/images with these approaches. Can someone suggest a module or a way to add social bookmarking icons to my site that only load or look for javascript only when executed?
Had this same issue on a site when using the Addthis widget and its probably similar for most sharing situations. We tried the addthis module but were also concerned about the overhead involved with loading the module and adding this on every page. We only wanted this to appear on blog posts so we wrote a simple preprocess_node hook to our module, ex:

if ($vars['type'] == 'blog_post') { 

    drupal_add_js('http://addthis.com/&lt;script-link-here&gt;.js', 'external');

}


And then added our specific call to AddThis in our blog post template. You could also add the script tag in your template as well but its not best practice and wouldn't get cached as well as if its done through drupal_add_js.

We considered caching the addthis file locally (which is allowed for by addthis) but resolved that it would be better performance-wise to shift the external load to their servers rather than adding another file hit to ours. This page may also be helpful for addressing performance concerns (for AddThis).