01 Jul 2020
Recently, I try to get TTI from WPT. I can find the TTI in its web app, but can’t find the TTI in its API response. So I do some reserach and found something:
WPT’s FirstInteractive === Lighthouse’s First CPU Idle WPT’s ConsistentlyInteractive === Lighthouse’s Time To Interac
So the WPT’s ConsistentlyInteractive is the TTI.
But I sometimes the ConsistentlyInteractive is missing in the API response. Then I found this:
Missing FirstInteractive and ConsistentlyInteractive are usually when there isn’t a 5-second window of idle in the main thread before the recording stopped so neither could be calculated.
So this means I can’t get TTI each time, because some website is too fast and finish before the TTI calculation.
But I want to get the TTI in each report. What should I do? After some research I found this:
timeToInteractive: firstInteractive || lastInteractive || timeToInteractive
But I still want to know why? So I got to check the TTI definition and TTI calculation.
TTI measures the time until the page being loaded is considered usable and will respond to user input. There are two variations on the metric: Time to Consistently Interactive: This was previously the only TTI measurement and measured the point where the page is likely complete and will consistently respond quickly. The canonical definition for it is here. Time to First CPU Idle (was First Interactive): This is a newer metric and reports when the page is first expected to be usable and will respond to input quickly (with the possibility of slow responses as more content loads).
That’s it. A clear explanation.