Watch the demo at bl.ocks.org.
Source and comments on gist.github.com.
Watch the demo at bl.ocks.org.
Source and comments on gist.github.com.
<body id=p onload=setInterval('z=p.innerText=Array(i=i*2%99).join(" ")+"*\\n"+z',i=z=80)> |
Let it snow, let it snow, let it snow!
<pre id=p><svg onload=setInterval('z=p.innerHTML=Array(Math.random()*80|0).join("\x20")+"*\\n"+z',80,z="")>
And another 3 bytes
<pre id=p><svg onload=setInterval('z=p.innerHTML=Array(Math.random()*80|0).join("\x20")+"*\\n"+z',80)>
Great <svg onload>
trick!
awesome work as always, folks!
Using the Unicode Character 'NO-BREAK SPACE' (U+00A0) will save another 2 bytes. Now down to 102 bytes.
<pre id=p><svg onload=setInterval('z=p.innerHTML=Array(Math.random()*80|0).join(" ")+"*\\n"+z',z=80)>
Using Array((i*=2)%79)
instead of Array(Math.random()*80|0)
will save some 8 bytes:
<pre id=p><svg onload=setInterval('z=p.innerHTML=Array(i=i*2%79).join(" ")+"*\\n"+z',i=z=80)>
PS: When using SVG.onload
it will give access to all it's properties:
<svg onload=console.log(outerHTML)>
Maybe we can use that here?
Using p.innerText
and custom x
tag makes ist 91 bytes:
<x id=p><svg onload=setInterval('z=p.innerText=Array(i=i*2%99).join(" ")+"*\\n"+z',i=z=80)>
Looks like good ol' <body id=p onload=
could save 2 bytes
Right! (o_#)
– now 90 bytes!
Thought about that but then the snow would not fall straight down as several spans of NBSPs could fit on the width of the window. :\
If you're all cool with this effect only working properly in a narrow viewport, then I believe we can replace the \n by a \t or even U+0009 character which saves 1 to 2 extra bytes
Nice... and dirty with the ever increasing innerHTML