Three Monkeys, Three Typewriters, Two Days

February 14, 2010

The pitfalls of comparing performance across browsers

From the source of a popular open-source rendering engine:

  // Flush out layout so it's up-to-date by the time onload is called.

From the source of another popular open-source rendering engine:

  // Make sure both the initial layout and reflow happen after the onload
  // fires. This will improve onload scores, and other browsers do it.
  // If they wanna cheat, we can too.

So if you're doing any sort of performance timing using onload and you're not flushing out layout yourself in a <script> at the very bottom of the page (because in some browsers loads of some subresources will actually start during layout) as well as right before taking your "load stop" timestamp (because there might be more pending layout at that point), and doing this in all subframes of your document, then you're comparing apples to oranges.

Too bad this is a common thing for people to do.

Posted by bzbarsky at February 14, 2010 10:29 PM