Aurochs.org

Tom's Excellent Javascript Snow Version 2

Behold: Tom's Excellent Javascript Snow: unobtrusive and customisable javascript snow for web pages using no images! Version 2, using canvas, and including an (optional) cheesy advent calendar feature.

A lot of this is customisable (including the optional cheesy advent calendar feature) by altering some of the options within the code. The options are in a separate section near the top and there are explanations. As the snow falls in front of the the we page content, the snow is disabled when the mouse is moved or clicked, so that links can be clicked and the page read as normal; snow resumes after a second or two.

The idea behind the original script 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 canvas 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. If you like, you can still see version 1 in action.

To use it, copy tomsnow_v2.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_v2.js"></script>
<script type="text/javascript">
function init () {
  snow();
}
window.onload=init;
</script>

In the unlikely event you do use this, do let me know for the sake of my own vanity. Any comments generally are welcome. 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