Safari 3 Benchmarking

Mark Wilton-Jones has written a detailed article on the behaviour and speed of Safari 3 in which he talks “how Safari fires onload at a different time than most other browsers”, and other implementation details that mean that you can’t trust JavaScript in the page to do any benchmarking. In Safari, it seems onload fires before the […]

Mark Wilton-Jones has written a detailed article on the behaviour and speed of Safari 3 in which he talks “how Safari fires onload at a different time than most other browsers”, and other implementation details that mean that you can’t trust JavaScript in the page to do any benchmarking.

In Safari, it seems onload fires before the page has been displayed, before layout has been calculated, before any costly reflows have taken place. It fires before images have completed loading (this can also happen in rare cases in Opera, but Safari seems to do it everywhere), meaning that a substantial part of the load time is not included. So basically, onload is not trustworthy in Safari for checking page loading times.

It is possible to force Safari to layout the page before checking for the time. To do this, check for the offset values of any element, such as the offsetWidth of the body:

window.onload = function () {
  var ignoreMe = document.body.offsetWidth;
  var endTime = new Date();
};

Full article

Apple, Sarari 3.0, Benchmarking, Article