Aurochs.org

Tom's Excellent Javascript Snow

Behold: Tom's Excellent Javascript Snow: unobtrusive and customisable javascript snow for web pages using no images!

I've been meaning to write this since last year when my attempts were full of fail. The idea was to create simple unobstrusive javascript snow that could be added to any page and that didn't require any images. I think Tom's Excellent Javascript Snow fulfills these criteria and is therefore full of win. Furthermore, it is very customisable, so you can easily alter the amount, speed, and style of snow, and so forth. Incidentally, it uses the asterisk character (*) by default. There is in fact a Unicode Tight Trifoliate Snowflake character, but it is only available in a few fonts by the looks of it and I haven't tried it. The script depends on the DOM and kind of uses CSS, but it is all defined through the Javascript: so many of the properties are different for individual snowflakes or change while the script is running, that it is not worth having a general style. It also means you only need one file to do everything.

To use it, copy tomsnow_v1.js to a directory on your web-server, and add the following code to the head of any pages on which you would like snow:

<script type="text/javascript" src="http://www.yourdomain.com/path/tomsnow_v1.js"></script>
<script type="text/javascript">
function init () {
  snow();
}
window.onload=init;
</script>

I'm sure Stuart will tell me there's a better way of doing it...

In the unlikely event you do use this, do let me know for the sake of my own vanity. Any comments generally are welcome. I do have some ideas for version 2, maybe for next year, mostly around wind effects such as better horizontal drifting, prevailing winds, and gusts. Ideally, I would like to make the snow lay in some way, as in the snow at St Pancras (you might have to wait for it to kick in), but that is quite unlikely given the trouble I had with page heights as it was.

Tom