Working on Idle Time

The requestIdleCallback()function waits for the main thread to be idle before executing the callback. This means that the callback won't get into the user's way. The user can still click buttons and type into inputs, the animations can still play, etc. This is particularly useful when you want to send analytics data or have non-essential DOM changes to make, such as adding items to the end of an ever-growing, lazy-loaded list.

Rapidly flickering, the number gradually increases as priority is given to the addition operation.
RESETRUNFULL
<!DOCTYPE html><html><head></head><body><div>0</div><script>var id;var e = document.querySelector("div");function add(){
    e.innerText = parseFloat(e.innerText)+1;}function subtract(deadline){
    if (deadline.timeRemaining()>12)   // 12ms free time
       e.innerText = parseFloat(e.innerText)-1;}setInterval(add,0);setInterval(()=>(id=requestIdleCallback(subtract,
                                                      {timeout:3600000})),
                            0);cancelIdleCallback(id);</script></body></html>