r/ComputerChess • • 16d ago

lightsquare: chessboard that animates with css transitions instead of js (5.2kb, MIT)

Post image

needed a board for my chess site. chessground is gpl so that was out (closed source site), and i didn't want to pull in react just for a board. ended up writing one.

what it does differently: moving a piece = set a transform + a css transition. compositor handles it, no rAF loop, zero js per frame. idle board = nothing running.

core is 5.2kb gzip, no deps. arrows / promotion / premove / a11y are separate imports, ~1kb each. react wrapper is 0.5kb. no chess logic in it, use chess.js.

bench vs chessground and react-chessboard (headless chromium, desktop, same script for all):

size 5.2kb / 11.9kb / 21.5kb + react

dom nodes 53 / 68 / 515

js per move 0.06ms / 2.8ms / 2.8ms

frames painted during a slide with the main thread blocked: 51 / 0 / 51

so react-chessboard is just as smooth, it's just heavier. it also beats me on compositing time. numbers and method are in the repo, including where i lose. i benchmarked after building it, not before.

1 week old, 0.1.x, api might change. running in prod on my site.

https://kibitzo.github.io/lightsquare/ (demo, has a bench page for your phone)

https://github.com/kibitzo/lightsquare

feedback welcome, esp. what's missing for you to use it

15 Upvotes

2 comments sorted by

2

u/treppenwitzmonk 16d ago edited 16d ago

5kb for a whole board is kinda wild. tried it on desktop and on my phone, feels really snappy

1

u/Low-Willingness-1961 16d ago

appreciate it. small and fast were the two things i refused to compromise on