The code itself is pretty simple stuff – three nested for loops and you’re basically done. A few little tweaks to make sure it runs fairly smoothly in all browsers. Unlike the PHP version you can’t really just set and forget, so I’m using setTimeout to break the task down into smaller chunks, which means the browser won’t trigger its “This script is running slowly” message. I also use window.scroll to show the user that something’s actually happening on screen.
The final minified code comes in at 713 bytes. I could get that down further for sure, but there’s no need to just yet.
Here’s the original source. Leave a comment if you can spot the IE errors :)