Skip to content

Instantly share code, notes, and snippets.

@Zizzamia
Last active October 9, 2018 02:54
Show Gist options
  • Select an option

  • Save Zizzamia/0cbf9a216066a381044f8a037a8fafee to your computer and use it in GitHub Desktop.

Select an option

Save Zizzamia/0cbf9a216066a381044f8a037a8fafee to your computer and use it in GitHub Desktop.
tti-polyfill demo
<head>
<script>
!function(){if('PerformanceLongTaskTiming' in window){var g=window.__tti={e:[]};
g.o=new PerformanceObserver(function(l){g.e=g.e.concat(l.getEntries())});
g.o.observe({entryTypes:['longtask']})}}();
</script>
<style>body { background: #f2db77; ... } .progress { ... }</style>
</head>
<body>...</body>
<script src="tti-polyfill.js"></script>
<script>
ttiPolyfill.getFirstConsistentlyInteractive()
.then((tti) => {
const elValue = document.querySelector('.js-tti-value');
elValue.textContent = tti + 'ms';
});
...
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment