JSFiddle - React, Tailwind, and code Playground

by Palpatim

HTML

<button id="start">Start</button>
<button id="stop">Stop</button>

JavaScript

var aId, bId;

function a(ts) {
    console.log('a', ts);
    aId = requestAnimationFrame(a);
}

function b(ts) {
    console.log('b', ts);
    bId = requestAnimationFrame(b);
}

var startButton = document.getElementById('start');

var stopButton = document.getElementById('stop');

function stop() {
    window.cancelAnimationFrame(aId);
    window.cancelAnimationFrame(bId);
}

function start() {
    a();
    b();
}

startButton.addEventListener('click', start);
stopButton.addEventListener('click', stop);