dont worry ill start doing this properly soon
Failed optimisation

Tried moving from pure string manipulation followed by converting to DOM
nodes to manipulating DOM nodes themselves with Zepto.js. It's a lot
slower.
More failed optimisation

Tried moving from using an intermediary DOM node not in the element tree
to directly manipulating $("#grid"). Performance went from ~14 ms to ~50
ms. Bad.
SUCCESSFUL OPTIMISATION

Down from ~7 ms to ~2 ms. What a leap.

Raw JS DOM manipulation is the best.

I even cleaned up the rendering code too!