JSFiddle - React, Tailwind, and code Playground

HTML

<button>Click Me</button>

JavaScript

$("button").one('click', DoSomething);

function DoSomething() {
  console.log('start handler');
    
  // Hot sleep for 2 seconds
  start = new Date().getTime();
  while (new Date().getTime() < start + 2000) {}

  $("button").one('click', DoSomething);
    
  console.log('end handler');
}