Home > Web Front-end > JS Tutorial > body text

13 JavaScript performance improvement tips to share_javascript tips

WBOY
Release: 2016-05-16 17:51:27
Original
1190 people have browsed it

Daniel Clifford gave a great talk "Breaking the JavaScript Speed ​​Limit
with V8" at Google I/O 2012. In the speech, he explained in depth 13 simple code optimization methods that can make your code compile/run your JavaScript code faster in Chrome's V8 JavaScript engine. In his speech, he explained how to optimize and why. The key points of optimization are briefly listed below:

1. Initialize all objects in the constructor

2. Always initialize objects in the same order

3. Try to Use numbers

4. Use consecutive primary keys starting from 0 for the array

5. Do not allocate large arrays (>64K) in advance, you should expand the array as you use it

6. Do not delete elements in the array

7. Do not load uninitialized or deleted elements

8. For fixed-size arrays, use "array literals" to initialize

9. Allocate the correct space size to small arrays before use

10. Do not store non-numeric content in numeric arrays

11. Try to use a single type (monomorphic) Instead of polymorphic

12. Do not use try{} catch{}

13. Avoid modifying hidden classes in methods after optimization

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!