portal to latire index

Premise

Javascript is ubiquitous on the internet, so I decided I would try make a chatroom without Javascript.

Design

Considering that the Tor browser disables Javascript by default[1], I decided to investigate how chatrooms on the Tor network were designed. I was somewhat disappointed that all the ones I could find used a <meta http-equiv="refresh"> tag. This tag simply refreshes the page on a timer. While this approach works, it seems wasteful to fetch every message in the chatroom repeatedly.

After a little more research I came across Chunked Transfer Encoding. It allows a server to stream HTML to the client one chunk at a time. The client keeps waiting for chunks until it receives an empty chunk. Most browsers will immediately begin rendering the HTML components as they are received and will generally continue to do so until the terminating chunk is received.

I decided this is what I would use to create my chatroom. The user sends a message via a <form> in an <iframe>. The server sanitizes the message, broadcasts it as an HTML chunk to each client, and reloads the form. The clients append received chunks to a separate chatroom <iframe> and wait for the next chunk. This repeats forever for a given client until it disconnects.

Conclusion

I made a chatroom that doesn't use Javascript, and doesn't refresh the entire page every few seconds. The tradeoff is that it uses Chunked Transfer Encoding in a way that it probably wasn't intended to be used and may have compatibility issues with some browsers. Check it out here.

Footnotes

[1] This is no longer the case. See https://support.torproject.org/tbb/tbb-34/