Ashes

JS1K

15 Feb 2013, 9:41PM

So I found this site and have since written two demos for it. Essentially they provide a page (they call it a shim) and you insert 1024 bytes of JS code into an inline script tag. What can you do with JS in 1k? You're not allowed to access outside resources (images/json/etc), its all in that 1k.

First demo is Texture Generator.

Second demo is Scroller (pending approval).

Half the work is in writing the demo, the other half in removing and compressing redundant lines. Minifying tools (I used Google Closure) go a good job but you still need a little more. I particularly liked the (dirty) use of eval('...').replace(\~\g, 'function'). E.g. storing my JS as a string, replacing all occurances of 'function' with a single character then evaling it. A simple form of compression really. I did the same for 'return'.

Need to stop now though, I could waste a lot of time doing this.

[UPDATE] So apparently this is the way to compress JS.

Previous
Next