When comments slow your JavaScript code (70% slower with long inner comments)
jsperf.com
jsperf.com
JSPerf test case has misleading name: it has nothing to do with inline caching, but it is indeed related to inlining heuristics. V8 uses source size in heuristics for historical reasons and source size includes comments (see the issue above for more info).
Saying that comments slow down your code by 70% is an exaggeration: if you remove all comments from your code it is unlikely that you will get 70% speedup across the board on V8, though potentially you might get some. Test case is really written in a way that highlights the issue, because loop itself is tight, it's doing nothing but a monomorphic function call and target function also is doing mostly nothing - this makes inlining of the callee essential for peak performance here. It is unlikely however that your code contains a lot of loops like this.
Absolutely agree.
https://gist.github.com/dazld/2a5dc58f5c9ce61bccae
Was about to start minifying all the server code too.. ;)
That however does not mean you need have to minify your server code.
Please don't base such decisions on some random microbenchmarks that have 0 connection to the code that you are really running in production.
Instead base these decisions on profiling of your actual application.
As I already said below: it is unlikely you get 70% improvement by removing all the comments in your code. For that you need an app that does nothing but a very hot tight loop calling the same small function that does almost nothing too.
Correct to point this out, especially considering the predilection of devs to micro-optimise based on the most spurious of hypotheses. Putting a single IO operation in that loop will most likely completely change the picture, anyway - although have not run the test to check.
I just used twitter to have many people testing in differents browser (and so JS engine) and so comparing behaviours :)