Javascript Widget Performance

Posted on by Todd Sampson

I received the following question today from Rustin over at The Blog Frog, a cool community service for mommy bloggers:

Like MBL, we use external javascript that is referenced from the blog. If our site ever goes down, even for 2 minutes, browsers try to load the javascript and pause for 30 seconds. Publishers then get upset that we are blocking their blog and take us off. How did you get around this with MBL? How did you display real-time data (when user visits their picture immediately shows up), but decouple from the database (which I assume was necessary)?

Since we have been asked this question more times than I can count, I figured it was time to post a quick response on the blog so anyone who is interested could benefit...

Image representing MyBlogLog as depicted in Cr...
Image via CrunchBase

Keeping the javascript from slowing sites down was absolutely the biggest technical challenge on MyBlogLog.  Once we sold MyBlogLog to Yahoo! we designed a massive, redundant architecture across multiple colos and countries to solve the performance issues.  That said, there are a number of things that anyone can do on the cheap to improve performance.  Off the top of my head, you could do any/all of the following:

  1. Move to an ajax/asynchronous load of the javascript widget.
  2. Move the main javascript to a CDN where you shouldn't have slowdowns.
  3. Have the CDN javascript call your servers to populate data, but gracefully timeout if it doesn't get a fast enough response.
  4. Move all member data into Memcached or similar memory caching layer on your servers.
  5. Make sure all javascript tags are set to defer load -- though browsers don't always implement this correctly.
  6. Use AmazonAWS or similar to setup multiple colos near users on the cheap.
  7. Move the tracking script lower in the page so it doesn't slow things down.

Finally, and most importantly, the system doesn't need to *be* real-time.  It just needs to *act* like it is real-time. We had a line in the javascript on MyBlogLog that automatically showed the current user visiting the site at the top of the list.  No database calls were needed.  Even better, since the user didn't have a clue who had visited the site just before them, we could cache the list of recent visitors every minute -- longer for sites with low traffic -- and show it below the current user.  This had a significant improvement in the end-user experience while costing us nothing.

Reblog this post [with Zemanta]
 
comments powered by Disqus