The famous A* / A-Star Search Algorithm, implemented in P5JS.
It is one of the most efficient Pathfinding-Algorithms. Think of it as a optimized Dijkstra's algorithm. The difference is that Dijkstra's algorithm expands in every direction, while A* / A-Star knows where the End-Node is and optimizes it's pathfinding towards that End Node. Therefor, it won't visit "unnecessairy" Nodes on it's way to the End-Node.