pengkobe / reading-notes

:stars: to record daily reading notes. I build an issue blog to record daily FE study notes. suggestion and comments are welcomed.
https://github.com/pengkobe/reading-notes/issues
MIT License
13 stars 1 forks source link

性能优化之js代码优化 #443

Open pengkobe opened 6 years ago

pengkobe commented 6 years ago

https://www.kancloud.cn/kancloud/web_performance_optimization/80999
优化原则:

根据不同引擎进行不同优化

例如FF、Opera和Safari的JAVASCRIPT引擎,都对字符串的拼接运算(+)做了特别优化

以大规模循环体为最主要优化对象

尽量避免过多的引用层级和不必要的多次方法调用

尽量使用语言本身的构造和内建函数

注意: 同样是内建特性,如 arguments 的访问性能就很差,几乎赶上一次函数调用了。