addyosmani / timing.js

Navigation Timing API measurement helpers
1.5k stars 114 forks source link

First Paint on Firefox #31

Open erakor opened 7 years ago

erakor commented 7 years ago

Hey, Currently, when browsing with Firefox, firstPaint is set to 0 because, I believe, Firefox doesn't support anything to measure properly. Should that value be set to null instead of 0 in that case?

atif089 commented 7 years ago

I see the same issue with Chrome 59 (on windows) as well

rjgotten commented 6 years ago

You should be able to get a decent approximation of first paint via the resource timing API, by using the maximum response end time out of all blocking CSS and script resources. I.e.

  1. Grab the list of resource timings with window.performance.getEntries("resource");
  2. filter to those with an initiatorType of 'link' or 'script';
  3. filter away those entries with a startTime later than window.performance.domInteractive as they were not loaded statically and would not block first paint; and
  4. finally take the maximum responseEnd of the remaining entries.