JSFiddle - React, Tailwind, and code Playground
HTML
<h1 id="media"></h1>
<h2 id="real"></h2>
JavaScript
let be = Date.now(),fps=0;
let count = 0;
let total = 0;
requestAnimationFrame(
function loop(){
let now = Date.now()
fps = Math.round(1000 / (now - be))
be = now
requestAnimationFrame(loop)
total += fps;
count ++;
document.getElementById('media').innerHTML = Math.round(total/count) + ' FPS';
document.getElementById('real').innerHTML = fps + ' FPS';
}
)