/* * Updated to use the function-based method described in http://www.phpied.com/social-button-bffs/ * but retaining the use of a document fragment to minimise the number of times objects are * written to the DOM. Also, better handling of scripts without supplied ids. * * N.B. Be sure to include Google Analytics's _gaq and Facebook's fbAsyncInit prior to this function. */ (function(doc, script) { var js, fjs = doc.getElementsByTagName(script)[0], frag = doc.createDocumentFragment(), add = function(url, id) { if (doc.getElementById(id)) {return;} js = doc.createElement(script); js.src = url; js.id = id || null; frag.appendChild( js ); }; // Google Analytics add(('https:' == location.protocol ? '//ssl' : '//www') + '.google-analytics.com/ga.js', 'ga'); // Google+ button add('https://apis.google.com/js/plusone.js'); // Facebook SDK add('//connect.facebook.net/en_US/all.js', 'facebook-jssdk'); // Twitter SDK add('//platform.twitter.com/widgets.js'); fjs.parentNode.insertBefore(frag, fjs); }(document, 'script'));