In the C++ world there are quite a few pathfinding libraries; the most popular one, in my opinion, is Recast & Detour. But even by reasonable standards it carries a lot of extra weight, it's quite large, and porting it to JavaScript makes it even bigger (1 MB). Since I understood how that library works, I decided to build my own almost from scratch rather than wrestle with porting. I based it on the A-Star search algorithm (A* for short). The A* algorithm is usually used for pathfinding on a 2D grid. But it also works perfectly for pathfinding across any connected nodes. You just need to find the center of each triangle and its neighbors, and you get nodes and links. However, the result is movement through the center points. To get an optimal path, shift the position from the center toward the nearest vertex of the triangle — that is our optimal path. The result of the algorithm: javascript-pathfinging-navigationmesh I solved the problem in just 800 lines, and the performance matches C++ equivalents. The size is 19 KB uncompressed and 6 KB with gzip. And we use no third-party libraries — there are no dependencies at all.
InteractivePathForgeInteractive 2D/3D polygon navmesh pathfinding demo. Click to load.

Interface updated in 2026.