Just recently I announced my new preferred development environment: HTML5, for my money saving reason: it’s free. So I figured to share some snippets of code I have tested that can optimize your HTML5 game (for free, heh)
- Objects. Creating a new object is slower, than compared to just setting existing properties of an object already declared. Its also best not to add a property to an existing object (aka expando object) – http://jsperf.com/object-set/2
- Math. Instead of calling Math.floor(n), use ~~(n) (Math.ceil is -~(n)) – http://jsperf.com/math-floor-vs-number-floor/3
- Objects/Arrays. When accessing a property multiple times throughout a function, make it a local variable for quicker indexing – http://jsperf.com/depth-namespace
I hope this helps speed up your games performance as it has done with mine. I will have more to share in the future. But for now, this is a good start.