Nitobi
About Nitobi
Services
Products
Home -> Blogs -> Dave Johnson

Dave Johnson

JavaScript Benchmarking - Part 1

July 10th, 2005

As the name suggests this is part I of a series of JavaScript benchmarking blogs. The reason for these is to investigate the performance of various Ajax programming tasks. The first entry investigates how the XSL-T processors of Internet Explorer and Firefox / Mozilla (on Windows 2000) compare and how they compare to pure Javascript code that arrives at the same end result.

So what I have done is loaded some XML and XSL for building a table structure in an HTML page. The transformation is timed and we take an average and standard deviaton for each browser. In Internet Explorer I used the Msxml2.DOMDocument.3.0 object and the XSLTProcessor in Firefox. The XSLT transformation speed is then also compared to a pure Javascript implementation. The Javascript implementation is the fastest method one can use to insert HTML into a web page [1]; a string array is used to store all the rows of the table after which the array join method is called to return a string that is inserted into the DOM using innerHTML, just as the XML/XSL approach does.

The results are somewhat surprising and can be seen below.


(note the y-axis should be in ms not s)

One can see that the XSL-T processor is Firefox / Mozilla leaves much to be desired and is no match for the Javascript method, nor is it any match for either the XSL-T or the Javasctipt method in Internet Explorer. On the other hand, the XSL-T and Javascript methods in Internet Explorer are more or less the same with a slight edge being given to the XSL-T method.

It is curious just how much variance their is on the Firefox XSL-T data. I am not sure what is causing this but all measurements were done 50 times to get the statistics and there was nothing significantly different on the system on which the tests were run.

So for the best cross-browser performance going with pure Javascript is not so bad when presenting large amounts of data to the user. Further tests will look at the performance of XSL-T and Javascript for sorting data, object and class level CSS manipulation and the recently released Google Javascript XSL-T [2] implementation.

These types of JavaScript speed issues are very important for companies like us [3] that make high performance Ajax controls and web based information systems.

[1] Quirksmode
[2] Google AJAXSLT
[3] eBusiness Applications

Del.icio.us

This entry was posted on Sunday, July 10th, 2005 at 10:42 am and is filed under Web, AJAX, JavaScript, XML, XSLT. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

3 Responses to “JavaScript Benchmarking - Part 1”

  1. runsun Says:

    You mentioned:

    “The Javascript implementation is the fastest method one can use to insert HTML into a web page [1]”

    and quoted [1].

    However, the quoted document on quirkmode doesn’t mentioned any javascript at all.

  2. Dave Johnson Says:

    Javascript method meaning the one where he concats the string to insert using Javascript and then uses innerHTML to get it into the DOM.

  3. Jess Says:

    I think, that computers so fast, that you can’t feel difference between browser’s speed.

Leave a Reply


Search Posts

Pages

Archives

Categories

All contents are (c) Copyright 2006, Nitobi Software Inc. All rights Reserved
Dave Johnson Entries (RSS) and Comments (RSS).