How do I 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).