First JavaScript version of shortest route