It's a text format record of game commands. I don't know that there's a complete specification available anywhere, but it should be relatively explanatory. It's space, semicolon, and new-line delimited, and is otherwise human readable.
It is not Javascript.
As far as compression goes, they're quite compressible already, but toribash.exe doesn't have any decompression built in to handle compressed replays. Without that, not much to be done. If your replay folder really is too big for your tastes though, turn on filesystem compression.