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?

4 Answers 4


Stockfish has been ported to Javascript:



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).


Depends what your definition of strong is, but my basic Javascript engine is probably about 2400 now (v1.16) and is still in development.

UI: http://op12no2.me/toys/lozza

Source: http://op12no2.me/toys/lozza/lozza.js

Typed arrays can be used for the hash table. It's client side browser based. The UI fires up a web worker which then uses UCI for comms, meaning the same code can also run offline in node.js (or jxCore), which in turn means it can be used in Arena and Winboard etc.

While Lozza is hand-written, another route (licence permitting) is to use Emscripten and asm.js etc to automate trans-compilation from C/C++. Some people have done this for Stockfish. I'm unsure the resulting ELO (probably better than Lozza) but the code is of course unreadable.



From a coding perspective one of the biggest drawbacks of Javascript is the lack of native 64bit unsigned integers.


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).

  • 4
    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. Mar 19, 2014 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. Mar 19, 2014 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, 2014 at 10:28
  • 1
    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. Mar 19, 2014 at 10:43
  • I agree with this comment, I use nodejs to talk to a c++ engine so it can take advantage of multithreading, popcnt, and NUMA memory optimizations
    – jaggedsoft
    Dec 7, 2016 at 21:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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