HTML5 Canvas performance: low-level optimization tips and tricks
http://www.elekslabs.com/2012/11/html5-canvas-performance-and_9.htmlLow-level optimizations matter even if you write your code in high-level language such as JavaScript. Code is still executed on same hardware as if you write it on C++. Each JavaScript engine is different. You can have significant performance boost in one browser, but at the same time your fix may make your code slower in another browser. Test your code in all browsers your application must work with. Keep the balance between code readability and performance considerations. Sometimes it makes sense to inline function even if it makes your code less readable. But always make sure that it brings you desired value: it doesn’t make sense to sacrifice code readability for 2 ms performance boost for code that is already fast enough. Think about object allocation, memory usage and cache utilization, especially if you work with memory intensive algorithms.