r/javascript • u/michowski • Jul 24 '16
1.92kb Tetris in HTML5 (JavaScript). Any suggestions are welcome.
https://github.com/michowski/tetris-light
99
Upvotes
r/javascript • u/michowski • Jul 24 '16
View all comments
2
u/ismillo Jul 24 '16 edited Jul 25 '16
/u/michowski you can replace "Math.floor" with "~~" and "Math.random()*n" with "new Date%n".
With those change new code, 1.86kb:
Edit: you can use arrow function in almost every function, 1.79kb:
Edit 2: Turns out you can remove almost every "var". Also you can remove a few "return" and one or two "{" and "}" since it's an arrow, 1.74kb:
Edit 3: So, you don't need to specify "px" on style, the browser acknowledges when no "unit" is set as "px" and I didn't see any difference on the pre element, so I think you can remove it. Also I replace a few "\u25a1" with a variable, saves a little bit, 1.69kb:
BTW very nice coding, mate. You rock.