Comcast / Surf-N-Perf

Micro-library for gathering web page performance data

Home Page:http://comcast.github.io/Surf-N-Perf/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Time to First Paint metrics

JohnRiv opened this issue · comments

Take a look at http://www.lognormal.com/blog/2013/11/11/calculating-first-paint/ and https://github.com/lognormal/boomerang/blob/master/plugins/navtiming.js and you'll see there are browser-specific ways to calculate first paint for recent versions of IE, Chrome & Firefox. Let's do the following:

  • add a getFirstPaint() method to Surf-N-Perf that returns the browser's native calculation, or null if the browser doesn't have one
  • add a getFirstPaintFrame() method will return an estimated value based on Window.requestAnimationFrame.
    • I assume that's going to require adding some code to the block we require in the <head> of the document.
    • If getFirstPaintFrame() is called but the data is not available yet, return undefinedNaN
    • If getFirstPaintFrame() is called but the browser does not support Window.requestAnimationFrame, return null

After we have that working: