A client of ours recently contacted me with the question: We use Keynote, WebPagetest and dynaTrace AJAX – but we get different results with these tools/services. WebPagetest tells us that our page is very slow – but dynaTrace on my local machine does not. What can be the problem here? What’s the difference?

I took a look at their page on my own laptop – running WinXP and IE8. I saw a small JavaScript performance hotspot but nothing major. Then it occurred to me that WebPagetest is probably using a different browser which made me notice a feature of IE that I haven’t yet explored enough.

IE Compatibility View

Internet Explorer 8 introduced a feature called Compatibility View. The intention of that feature was to allow web sites that were optimized for older browser versions to display correctly and it also allows developers to test what their site looks like on an older version of IE. From a performance analysis perspective this feature also allows you to verify if your site has been optimized for multiple versions of IE – without needing a second machine that runs an older browser.

Comparing Page Speed

I ran the page that was supposed to be slow twice – once without and once with the Compatibility View. The following two illustrations show the dynaTrace AJAX Timeline View of the same page (first one is normal IE8 – second is the one using Compatibility View):

Timeline for page in IE8 showing about 3 seconds in onLoad/readyStateChange event handler
Timeline for page in IE8 showing about 3 seconds in onLoad/readyStateChange event handler
Same page in Compatibility Mode takes 10 seconds for the same JavaScript handler
Same page in Compatibility Mode takes 10 seconds for the same JavaScript handler

Identifying JavaScript HotSpot

The latest dynaTrace AJAX Edition 2.0 Beta 1 has a new Performance Report feature that highlights the JavaScript hotspots for me. The following illustration shows a side-to-side comparison of the identified HotSpots in IE8 Normal Mode vs. Compatibility View:

Very long running jQuery lookups in Compatibility Mode vs. very fast in IE8 Normal Mode
Very long running jQuery lookups in Compatibility Mode vs. very fast in IE8 Normal Mode

The difference between these two runs is caused by the jQuery lookups on elements identified via their class name or complex lookups with parent->child relations. I wrote an article that explains the performance implications of these lookups and listed other JavaScript/AJAX recommendations in our Best Practices on JavaScript and AJAX Performance.

What is the performance difference in those jQuery Lookups?

When we drill down into the PurePath on both recorded sessions it is easy to spot where the difference comes from:

IE8 supports querySelectorAll whereas previous IE versions do not causing jQuery to manually iterate through ALL DOM elements
IE8 supports querySelectorAll whereas previous IE versions do not causing jQuery to manually iterate through ALL DOM elements

I’ve said this many, many times on this blog: Element lookups by class name or any lookups not done by ID or TagName are EVIL in Internet Explorer. IE8 at least provides an implementation of querySelectorAll which the latest versions of frameworks like jQuery support – but be aware of some restrictions and concerns.

My new friend: the Compatibility View

Compatibility View is definitely a huge help for developers and testers. It allows us to test the same page on the same machine with two major versions of IE. For testers this is nice as they can run the same set of tests against the same installed browser but in different modes (however – I still recommend using two real, different browsers on different machines – because – in the end – the compatibility view is not the real thing). Use tools like the dynaTrace AJAX Edition to analyze the difference performance behavior of your pages.