Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 28th, 2012  |  syntax: None  |  size: 0.96 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /*
  2.  * Updated to use the function-based method described in http://www.phpied.com/social-button-bffs/
  3.  * Better handling of scripts without supplied ids.
  4.  *
  5.  * N.B. Be sure to include Google Analytics's _gaq and Facebook's fbAsyncInit prior to this function.
  6.  */
  7.  
  8. (function(doc, script) {
  9.     var js,
  10.         fjs = doc.getElementsByTagName(script)[0],
  11.         add = function(url, id) {
  12.             if (doc.getElementById(id)) {return;}
  13.             js = doc.createElement(script);
  14.             js.src = url;
  15.             id && (js.id = id);
  16.             fjs.parentNode.insertBefore(js, fjs);
  17.         };
  18.  
  19.     // Google Analytics
  20.     add(('https:' == location.protocol ? '//ssl' : '//www') + '.google-analytics.com/ga.js', 'ga');
  21.     // Google+ button
  22.     add('https://apis.google.com/js/plusone.js');
  23.     // Facebook SDK
  24.     add('//connect.facebook.net/en_US/all.js', 'facebook-jssdk');
  25.     // Twitter SDK
  26.     add('//platform.twitter.com/widgets.js', 'twitter-wjs');
  27. }(document, 'script'));