How can I optimize this pathfinding visualization

Have you tried reducing the amount of times the path computes and lerping it between computations? How about making the visualization loop only on the client?