16
A Super Bowl experience: How third party scripts can hurt your website
1 Comment · Posted by Patrick Lightbody in Load Testing Tips
I just recently came across a great article titled How tracking scripts affect page loads… can Google Analytics kill my web app?:
This post explains script blocking, and then shows how to safely setup a tracking script or any external script, such as Google Analytics or Quantcast, to not block page loads or other javascript handlers on your site.
It’s a great read and provides a clear explanation on how third party components (everything from advertisements to analytics to content widgets) can slow your site down. JavaScript includes have been commonly used in websites for coming on a decade, but there are still many people who don’t understand the destruction a rogue script can cause to user experience.
One such example of that kind of destruction recently happened to customer of ours who ran an advertisement during the Super Bowl. In the weeks and months leading to the event, they had done massive amounts of tests and verified that their data center could easily handle 2.5 gigabits per second or more.
They were more than prepared and, overall, the event went off without a hitch. However, there was one minor problem that did plague their launch: a third party that served a component on their site couldn’t keep up with the load.
It turns out that one page (unfortunately, an important one that allowed visitors to search for their products) included an inline JavaScript file hosted externally. This included file was added at the last minute and didn’t get subject to the intensive testing that the rest of the site had gone through.
When the external site went down, visitors’ browsers would timeout after 1-2 minutes of trying to fetch that content before finally firing the important onload event in the browser. Nothing hosted by the company had a problem, but yet it still affected the user experience.
To make matters worse, the customer did have certain JavaScript that fired on the onload event. This JavaScript added rich functionality, such as making a calendar pop up when clicking on a date field. Because of the 1-2 minute delay, this functionality wasn’t available immediately, causing the experience to deteriorate.
In addition to all the guidance given in the aforementioned article, there are two things they can do to avoid this next time:
- Remove the third party reference entirely. In this case the reference was to some JavaScript that in turn produced a “Follow me on Twitter” image. That image could have easily been hosted in their own data center, which had been tested thoroughly.
- Take advantage of the “on content ready” psuedo event. Most modern JavaScript frameworks support a non-standard event that will fire before onload. Most of the time, this is much more desirable as it means that the JavaScript will fire closer to when the user sees content in their browser – not just when all images and JavaScript has been downloaded.
The “on content ready” psuedo-event doesn’t have an official name, but a lot of people also refer to it as “on DOM ready”. YUI, Dojo, Prototype, jQuery, and many others support it, so be on the lookout.
1 comment
Leave a Reply
<< Case Study with SignalFive for Al Gore’s Alliance for Climate Protection

Peter Coles · February 28, 2010 at 6:40 pm
Great example of an external script causing trouble! Testing a live site is a difficult task. I saw a similar example recently where an advertisement script was bogging down a page. I added the screen shots to my blog post (referenced at the top of this one) so people can see how it blocks all the useful content on the page (and load/ready events) from appearing until the ad finally timed out.
Also, a minor clarification, the “on content ready” pseudo event will not get blocked by images, but it will get blocked by any slow scripts. So while it is a better/safer event than window.onload for applying functionality to a web page, it still has to wait for slow scripts.