Wednesday, June 30th, 2010

IE9 gets a Web Timing API to measure performance

Category: IE, Microsoft, Performance

<>p>Web site performance is a very important topic. We should not let our end users wait for our sites and optimizing them for load time and rendering can save us thousands of dollars in traffic. There is a lot of great content out there on performance (spearheaded by Yahoo a few years back). When it comes to testing the performance after the page has loaded though there is a lot of things you can do wrong as you need to test things with timers and hope nothing else happening to your test machine interferes with your results.

The IE9 team wants to make it easier for developers and added a new Web Timing API in the browser. Web Timing is a W3C working draft and the API implemented the NavigationTiming part of the spec in window.msPerformance.timing and offers you a few sets of information without having to hack your own solution:

javascript
< view plain text >
  1. interface MSPerformanceTiming{
  2.      readonly attribute unsigned longlong navigationStart;
  3.      readonly attribute unsigned longlong fetchStart;
  4.      readonly attribute unsigned longlong unloadStart;
  5.      readonly attribute unsigned longlong unloadEnd;
  6.      readonly attribute unsigned longlong domainLookupStart;
  7.      readonly attribute unsigned longlong domainLookupEnd;
  8.      readonly attribute unsigned longlong connectStart;
  9.      readonly attribute unsigned longlong connectEnd;
  10.      readonly attribute unsigned longlong requestStart;
  11.      readonly attribute unsigned longlong requestEnd;
  12.      readonly attribute unsigned longlong responseStart;
  13.      readonly attribute unsigned longlong responseEnd;
  14.      readonly attribute unsigned longlong domLoading;
  15.      readonly attribute unsigned longlong domInteractive;
  16.      readonly attribute unsigned longlong domContentLoaded;
  17.      readonly attribute unsigned longlong domComplete;
  18.      readonly attribute unsigned longlong loadStart;
  19.      readonly attribute unsigned longlong loadEnd;
  20.      readonly attribute unsigned longlong firstPaint;
  21.      readonly attribute unsigned longlong fullyLoaded;
  22. }

You have even more granular control in timingMeasures

javascript
< view plain text >
  1. interface MSPerformanceTimingMeasures{
  2.      readonly attribute unsigned longlong navigation;
  3.      readonly attribute unsigned longlong fetch;
  4.      readonly attribute unsigned longlong unload;
  5.      readonly attribute unsigned longlong domainLookup;
  6.      readonly attribute unsigned longlong connect;
  7.      readonly attribute unsigned longlong request;
  8.      readonly attribute unsigned longlong response;
  9.      readonly attribute unsigned longlong domLoading;
  10.      readonly attribute unsigned longlong domInteractive;
  11.      readonly attribute unsigned longlong domContentLoaded;
  12.      readonly attribute unsigned longlong domComplete;
  13.      readonly attribute unsigned longlong load;
  14.      readonly attribute unsigned longlong firstPaint;
  15.      readonly attribute unsigned longlong fullyLoaded;
  16. }

Read the original post on MSDN and check out the demo on IE Test Drive

Related Content:

Posted by Chris Heilmann at 3:15 am
1 Comment

+++--
3 rating from 2 votes

1 Comment »

Comments feed TrackBack URI

Zhiheng over here at Google has been working on that draft spec for months. It’s incredibly important to the W3C spec process to have this reference implementation. It’s a really positive reflection on the IE9 team that they’re the first ones to offer it. Remember – the spec is still in draft and undergoing revisions. (Great move by IE9 to put it under window.msPerformance until the spec settles down.) Give it a try!

Comment by souders — June 30, 2010

Leave a comment

You must be logged in to post a comment.