JavaScript Optimization: How Resource-Consuming Call Chains?
Note: below is the translation of the article “JavaScript optimization, are chained calls expensive?” .In it, the author tests how much slower the chains of function calls are made compared to their cached counterparts.At the end are the results of my performance tests
To understand the differences for the simplest case that follow from the understanding of the (obvious) basics of JS optimization, it is worthwhile to realize that:
for (i = 0; i <100; i ++) abcd (v);
')
... SIGNIFICANTLY slower, at least in JavaScript, than:
var f = abcd;
for (i = 0; i <100; i ++) f (v);
... because, after all, JS is a dynamic language. I will provide some more specific javascript tips and performance tests that will clarify this situation.