-
-
Save madrobby/934008 to your computer and use it in GitHub Desktop.
// tweet-sized, and does (approximately) the same thing | |
var t=document.all,l=t.length,w='-webkit-trans';while(l--)t[l].style.cssText+=w+'ition:all,20s;'+w+'form:rotate('+Math.random()+'rad)' |
And starting i to 0 and i++ in place of ++i : 137 characters. Still no errors.
i=0,w='-webkit-trans';while(e=document.querySelectorAll('div')[i++])e.style.cssText+=w+'ition:20s;'+w+'form:rotate('+Math.random()+'rad)'
w="-webkit-trans";i=0;while(e=document.querySelectorAll("div")[i++])e.style.cssText+=w+"ition:20s;"+w+"form:rotate("+i/10+"rad)"
109: like @joside's but with *
instead of div
s='-webkit-trans';document.styleSheets[1].addRule('*',s+'ition:20s;'+s+'form:rotate('+Math.random()+'rad)')
Edit:
Not sure where the 20s came from but 9s looks just as good:
s='-webkit-trans';document.styleSheets[1].addRule('*',s+'ition:9s;'+s+'form:rotate('+Math.random()+'rad)')
I think @joside has won this game.
@marcheiligers : what if there is actually not any document.styleSheets ?
Should be able to get it to work in Opera with '-o-trans'
, which would shave 5 chars but I can't get it to work :-(. Means you loose 1% of browser market share though.
[].map.call(document.all,function(e,s){s='-webkit-trans';e.style.cssText+=s+'ition:20s;'+s+'form:rotate('+Math.random()+'rad)'})
Array.prototype.slice.call(document.all).forEach(function(e,s){s='-webkit-trans';e.style.cssText+=s+'ition:20s;'+s+'form:rotate('+Math.random()+'rad)'})
137 chars, only divs, no errors, based on @jedisct1 loop with querySelectorAll
If I could save one more char somewhere the var could go back in :-(
for(i=0,w='-webkit-trans';e=document.querySelectorAll("div")[i++];)e.style.cssText+=w+'ition:20s;'+w+'form:rotate('+Math.random()+'rad)'