Polyfill for Time to Interactive. See https://goo.gl/OSmrPk
npm install overlooker-tti-polyfillTime to Interactive Polyfill
============================
This is a fork of https://github.com/GoogleChromeLabs/tti-polyfill.
A polyfill for the Time to Interactive metric. See the metric definition for in-depth implementation details.
You can install the TTI polyfill from npm by running:
``sh`
npm install tti-polyfill
Adding the TTI polyfill is a two-step process. First you need to add a snippet of code to the head of your document (before any other scripts run). This snippet creates a PerformanceObserver instance and starts observing longtask entry types.
`html`
__Note:__ this snippet is a temporary workaround, until browsers implement level 2 of the Performance Observer spec and include the buffered flag.
The second step is to import the module into your application code and invoke the getFirstConsistentlyInteractive() method. The getFirstConsistentlyInteractive() method returns a promise that resolves to the TTI metric value (in milliseconds since navigation start). If no TTI value can be found, or if the browser doesn't support all the APIs required to detect TTI, the promise resolves to null.
`js
import ttiPolyfill from './path/to/tti-polyfill.js';
ttiPolyfill.getFirstConsistentlyInteractive(opts).then((tti) => {
// Use tti value in some way.`
});
Note that this method can be invoked at any time, it does not need to be called prior to interactivity being reached. This allows you to load the polyfill via