This is an attempt to see how small a pure HTML playable TicTacToe game can be. The first script (ttt.py
) generates a 560KB HTML file.
- The game is playable at https://pablo.rauzy.name/dev/ttt.html
I made it in reaction to this Hacker News post: Implementing Tic Tac Toe with 170MB of HTML – No JavaScript or CSS, because my reaction to "170MB" was "wait, WAT?".
The second script (ttt_smaller.py
) is an attempt to go further, by shortening IDs to maximum 2 chars rather than using 9 characters for full board descriptions as IDs. It does so by using a custom base74, because 74 + 74 × 74 = 5550 which is just above the 5478 game states that have to be represented.
This optimization allows to get down to 412KB, that is a saving of 148Ko, i.e., a 26% size-reduction!
- This smaller version of the game is playable at https://pablo.rauzy.name/dev/ttt_smaller.html
UPDATE: The ttt_smallerer.py
version of the script available below goes even further and generates a 367KB HTML file, these 45Ko are saved essentially by removing quotes around HTML attributes…
- This smaller version of the game is playable at https://pablo.rauzy.name/dev/ttt_smallerer.html
I also made "pretty" versions that use a minimal amount of CSS (54 bytes!) and a bit more HTML structure:
- https://pablo.rauzy.name/dev/prettty.html is 598KB.
- https://pablo.rauzy.name/dev/prettty_smaller.html is 450KB.
- https://pablo.rauzy.name/dev/prettty_smallerer.html is 407KB.
Added CSS: pre{font-size:20pt;display:none}:target{display:block}
.