• Measure time starting at event.timeStamp.
  • Measure time ending at performance.now() in a requestAnimationFrame(). performance.now() is precise to ±100 microseconds.
  • Ensure your app is in the foreground because if your user switches to another browser tab, your metrics will break. Use document.hidden and visibilitychange event. While the tab is in the background, document.hidden is true.
  • Find the best event start time. For a current event, use window.event.timeStamp to record the time the system logged the event.

Full post here, 8 mins read