Take the 2-minute tour ×
Chess Stack Exchange is a question and answer site for serious players and enthusiasts of chess. It's 100% free, no registration required.

In one of my previous questions I asked about comparison of the strongest chess engines and got a really good answer. While there are little or no doubts that chess engines are stronger than humans, I am curious: Is there any strong javascript implementation of a chess engine that performs well (what is the ELO of the engine)?

Knowing that a lot of high level chess engines are opensource, has anyone made an effort to port something like stockfish or critter to JS?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

After a detailed look on the web, the only project I was able to find is Garbochess. It is BSD licensed, but it looks like it is not longer under development (latest commit was a year ago). I also was not able to find anything about the strength of the engine (ELO).

share|improve this answer
Thanks, I downloaded it works. –  LayoutPH Mar 19 '14 at 5:01

Edit: This answer has been written by someone who is unexperienced in JavaScript programming (me). Please note the comments shed a slightly different light on the topic.

One of the reasons there are not many JS chess engines out there is that JavaScript is quite unsuited for heavily parallelisable tasks, especially complex minimax analysis.

Major drawbacks JS has (in my opinion) are:

  1. JavaScript is a high level language, making writing fast code difficult. (Of course I have to add that coding in ASM or C isn't going to be faster if you don't know what you are doing. But chess programmers know.) Additionally, performance optimisation details depend on the browser you are using.
  2. No real multithreading support. (That's a damn hard limit on computation speed.)
  3. No real memory management. (JS does it for you, but I imagine you as a programmer can allocate much more efficiently.)
  4. Apparently, limits on stack size, CPU usage etc. are imposed on JavScript Code (although Icannot give hard evidence right now).
  5. I cannot imagine JS being very efficient with hash tables.
  6. I imagine it being difficult to load opening books or endgame tablebases during runtime (slow) or preloading it on startup (still slow and your bandwidth won't like it).

Well, technically, these are reasons why it would be hard to code a good chess engine - but who wants an engine with 1800 Elo? (Well, still enough for one or two standard deviations of players' practical purposes.)

And in the end: it's client side. If you need something client side, don't do it in a browser. If it can be done on the server, use it! E. g., using PHP, pipes and the UCI protocol, you'll get much further and you can let the server compute it for all clients (and I know it has been done before, but can't tell exactly where I've seen it).

share|improve this answer
As a programmer, I can tell that there are inaccuracies in the post. JS is also run on the server (node.js) and it performs pretty good. Nevertheless the execution is definitely slower than C (it improves with every new browser version), but writing the code is much faster. Multithreading is achieved with web-workers and is pretty good. JS can also take use of gpu through WebCL. Javascript object {a: 1, b: 2} is actually a hash table (so it has native support). Loading opening book - yes, this is true... Although right now JS supports p2p with WebRTC, so you can paralelize your AI tasks. –  Salvador Dali Mar 19 '14 at 10:25
By the way - check the engine I found. It was done by one guy and I think that it is stronger than 1800. –  Salvador Dali Mar 19 '14 at 10:26
I'm not using JS that often, so thanks for correcting me. Would you still agree with my conclusion that outsourcing the task to a UCI engine on a server would be the better option in most cases, though? –  chaosflaws Mar 19 '14 at 10:28
Sure, and it was the only option like 3 years ago. But imagine the following situation. There are 20 users. Each of them wants to analyse some position. Server will not handle even 2 of them. I have no illusions that JS engine will perform faster than C. I was curious about the current situation for JS engines. –  Salvador Dali Mar 19 '14 at 10:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.