Title: Recently a lot of sites are getting slow for me. The reason? They add a lot of social submit widgets that use non-async scripts.<p>If you see a substring &#60;script src="http:// or &#60;script src="https:// in your HTML source - you are killing your site slowly.<p>Using Twitter's official ReTweet button? You've slowed your site down by 60 seconds per each page (I don't know how many people are affected by this hiccup that lasts more than 5 days now for me, but you can easily fix it for everybody, see below)<p>Just to be clear. I'm on 35Mbps line in Russia near Moscow (4.3MBytes/s - very fast! 4ms ping to national traffic exchange point in Russia).<p>Yet some sites load up to 2-5 minutes for me? Why?<p>According to Chrome Dev Tools I receive main blog content, including all images within 1-2 seconds. (It's a 35Mbps!), but I don't see anything from your site on screen (even though it has finished loading), because...<p>"platform.twitter.com" responds in 49-62 seconds! Uses &#60;script src="http://... for their "retweet" button. Your site is STUCK until "platform.twitter.com" loads (1 minute).<p>Facebook's CDN responds within 30-50 seconds. The site doesn't load until it's loaded.<p>"www.stumbleupon.com"'s button loads in 20 seconds.<p>I'm not sure what the problem is, but I can tell you for sure - it takes minutes to load some sites with those buttons, it takes less than a blink after I add "127.0.0.1 platform.twitter.com" and others to /etc/hosts (that's not a way to solve it, it's a way to diagnose the problem, see below for solution).<p>Many of you use a lot of those buttons in hope that they will bring you visitors. But while they load - they lose you visitors that have to wait 2 minutes for your page to load.<p>WordPress' social submit plugins are often have the same effect on your site.<p>The solution? Use async code and ask your plugin developer to move to async code.<p>It's not some futuristic HTML5 goodie that works only in modern browsers. It works everywhere.<p>Facebook has async code - use it! 
Google Analytics has async - use it!<p>Twitter doesn't give out async, but it's easy to do it, based on FaceBook and Google Analytics code:<p><pre><code>  &#60;a href="http://twitter.com/share" 
  class="twitter-share-button" data-count="horizontal" 
  data-via="WhitePostsCom"&#62;Tweet&#60;/a&#62; 
  
  &#60;script&#62; 
    (function() {
    var src = document.createElement('script'); 
    src.async = true;
    src.src = document.location.protocol + '//platform.twitter.com/widgets.js';
    document.getElementsByTagName('head')[0].appendChild(src);
    }());                        
  &#60;/script&#62; 
</code></pre>
Replace the first part with your own code instead of WhitePostsCom one.<p>StatCounter doesn't give async, adapt it from the code StatCounter gives you: 
(There was a day when StatCounter didn't load in 2 minutes! Your site is stuck again if you don't do async)<p><pre><code>  &#60;!-- Start of StatCounter Code --&#62;
  &#60;script type="text/javascript"&#62;
  var sc_project=[YOUR CODE HERE]; 
  var sc_invisible=[YOUR CODE HERE]; 
  var sc_security="[YOUR CODE HERE]"; 
  (function() {
      var ga = document.createElement('script'); 
      ga.type = 'text/javascript'; ga.async = true;
      ga.src = document.location.protocol + '//www.statcounter.com/counter/counter.js';
      var s = document.getElementsByTagName('script')[0]; 
      s.parentNode.insertBefore(ga, s);
  })();
  &#60;/script&#62;
  &#60;noscript&#62;&#60;div
  class="statcounter"&#62;&#60;a title="web analytics"
  href="http://statcounter.com/" target="_blank"&#62;&#60;img
  class="statcounter"
  src="[YOUR CODE HERE]"
  alt="web analytics" &#62;&#60;/a&#62;&#60;/div&#62;&#60;/noscript&#62;
  &#60;!-- End of StatCounter Code --&#62;
</code></pre>
StumbleUpon? Adapt it from the above codes.<p>Seeing someone asking you to insert '&#60;script src="http://' into your code? Tell them to do better engineering and stop slowing down your site.<p>P.S. The reasons for hiccups of Twitter and FB's CDN might be poor peering, bad servers, anything really. You can't fix Twitter's and Facebook's software and servers, but you can let your visitors see your site without depending on how good do engineers at those companies do their job.<p>P.P.S. There is a good question in comments about how to diagnose your own site's problems: http://news.ycombinator.com/item?id=1771755<p>Problematic hosts list (the srcs that cause sometimes huge slowdowns for me) - just in case you need it:<p><pre><code>  widgets.digg.com
  platform.twitter.com
  static.ak.fbcdn.net
  www.stumbleupon.com
  i.ixnp.com</code></pre>
Upvote: