console.log Will Cost You Browser Ops

Writing log statements in your javascript code is a habitual practice for web developers. But if you do not comment them out you might be giving up performance for nothing. This is the single most simple tweak you can do to your code to speed up javascript execution. Remember to comment out those log statements before you push code to production. This is a bigger problem for mobile browsers because every browser operation is important with that limited processing power your app gets.

To see how leaving console.log statements in your code can affect performance. Look at this jsperf test I wrote.

Advertisements