I'm testing if it works and a function that runs a while loop will block the code even if it is in an asynchronous function that I am awaiting. How do do something like pathfinding without freezing my webpage?
Doing work keeps the main JS event loop busy.
You can't get around that by using promises or the async and await tools. They are tools to manage asynchronous code, they don't make code asynchronous.
A couple of strategies you could employ are:
setTimeout to introduce a delay during which the main event loop can pick up other work that is waiting for it.