|
Comments
Did you read today's front page stories & breaking news?
SYS-CON.TV
|
Features Understanding Twitter’s JavaScript in Multiple Browsers
How to profile, debug and trace across Firefox and IE 6,7,8
By: Andreas Grabner
Dec. 29, 2010 09:30 AM
Every time I meet up with web developers, either through a customer engagement or when I am giving a presentation about web performance optimization, I ask this question: Who is using Firefox and who is using Internet Explorer as the main browser? The answer is easy to guess. I hardly ever get any hands raised for Internet Explorer. And honestly – I don’t blame them as there are so many great tools on Firefox such as Firebug or YSlow that are great to profile and debug your web application. The problem though is that a big majority of their end-users are going to use Internet Explorer (46% market share in Nov 2010) and might not be happy with their end-user-experience. Check out the following articles for more details on bad performing web sites in Internet Explorer: Top 10 Client-Side Performance Problems in Web 2.0. As recently announced on our blog there is a solution to that problem – dynaTrace AJAX Edition is extending its browser support to Firefox. This not only allows you to profile, debug and trace your web site’s performance – the great thing is that it is a single tool that does this for the two major browsers allowing you to compare side-by-side how well your code works on both browsers and gives you an idea of where to optimize. Compare a Twitter Search in FF and IE Step 1: Performance Report There are several interesting things here: Firefox was slower with the onLoad time but faster with the Fully Loaded Time. It also requested 5 fewer resources than Internet Explorer. Now – we have to be careful with timings here as this is just a single test sample. It would be better to run multiple tests on each browser and look at average values across tests to rule out volatile results. But it is an interesting observation. We have to ignore the First Impression Time for now as the version of Firefox I use doesn’t yet support true Rendering Time capturing (coming soon). Step 2: Network Differences We can see that one of the Network Differences is the first embedded CSS File that IE starts to download. It starts downloading it but doesn’t finish as an inline JavaScript function changes the window.location and forces an abort of all other downloads. Firefox seems to show a different behavior where it does not start downloading embedded resources before the inline JS gets executed. This, however, could also just be timing related. In any case, a good practice here would be to place the inline JavaScript that forces a redirect to a different URL to the very top. This will eliminate unnecessary requests. The Timeline View of this part shows us what happens in IE and in FF: The other difference in network requests were two extra tweets that were not displayed in Firefox – probably because I executed the query at a slightly different time and these two older tweets didn’t make it in the default results list. Step 3: Timeline of complete Page Load As I said in the beginning – we should do multiple test runs in order to rule out outliers. But still – what we can see here is that Firefox is faster with downloading all the network resources. This is mainly explained due to the fact that Firefox uses more physical connections per domain to download resources. What is really interesting is the big JavaScript Execution block. I would have assumed that Firefox is faster in JavaScript execution – in fact it turned out that IE was slightly faster. Hovering with the mouse over the big red block shows 1.136s for IE and 1.317 for FF. Overall there is still a little more JS Execution Time in IE as the script blocks at the beginning of the page take longer. But – let’s have a closer look at the JavaScript execution. Step 4: Compare JavaScript Execution The real surprise from my perspective – based on all the blogs I wrote about CSS Lookup Performance in IE – is that Firefox is slightly slower in iterating through the DOM to lookup those DOM elements, e.g.: “.status-body a,.vcard a”. What is less surprising is that renderResultsFromSummize is faster in Firefox. If we take a deeper look into that method we see that it actually modifies the DOM by creating all those DOM objects as passed in the string parameter through jQuery helper methods. Especially changing innerHTML seems to be much faster in Firefox than IE. There are a total of 98 innerHtml changes in my example taking 87ms on IE and only 45ms in FF. Another way to look at JavaScript is to look at the Hotspot View which represents an aggregated view on all JavaScript, DOM and Rendering traces. The Hotspot View allows us to answer different types of questions such as which methods were invoked how often (sort by Invocation), which methods have a long Execution Time (sort by Exec Avg.) or which methods have a long Total Time (sort by Total Avg): Conclusion Related reading:
Latest Cloud Developer Stories
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
|
SYS-CON Featured Whitepapers
Most Read This Week
Breaking Cloud Computing News
|
|||||||||||||||||||||||||||||||||||||||||||||||||