Perhaps you could consider wrapping your function inside setTimeout as it uses the browser's Web API to handle the delay externally, allowing JavaScript to continue running
setTimeout
setTimeout(()=>{ // function })
https://medium.com/@ashishkumarjena1437/understanding-how-settimeout-works-in-javascripts-single-threaded-environment-dd5889ea1599#:~:text=JavaScript%20is%20single%2Dthreaded%2C%20meaning,moves%20to%20the%20callback%20queue.