If you haven't seen it yet, check out the JS1K demo contest. The goal is to do something neat in 1 kilobyte of JavaScript code.
I couldn't resist making one myself, so I pulled out my bag of tricks from my Winamp music visualization days and started coding. I'm really happy with how it turned out. And no, it won't work in Internet Explorer:
Original Version
Edit: OH SNAP! I just rewrote the demo to include volumetric light beams and still fit in 1K:
New and Improved Version
(the music is not part of the 1K, but it does make it more enjoyable)
Now, whenever size is an issue, the best way to make a small program is to generate all data of the fly, i.e. procedurally. This saves valuable storage space. While this might seem like a black art, often it just comes down to clever use of (high school) math. And as is often the case, the best tricks are also the simplest, as they use the least amount of code.
To illustrate this, I'm going to break down my demo and show you all the major pieces and shortcuts used. Unlike the actual 1k demo, the code snippets here will feature legible spacing and descriptive variable names.





