13 tips for improving JavaScript Performance

Source: Internet
Author: User

Daniel Clifford gave a wonderful speech at Google I/O 2012, "Breaking the Javascript Speed Limit
With V8 ". In his speech, he explained 13 simple CodeThe optimization method allows your code to compile/run your JavaScript code more quickly in Chrome's V8 JavaScript Engine. In his speech, he explained how to optimize and why. The following briefly lists the key points of optimization:

1. Initialize all objects in the constructor

2. Always initialize objects in the same order

3. Use numbers whenever possible

4. Use a continuous primary key starting from 0 for the Array

5. Do not allocate large arrays (> 64 K) in advance. You should expand the array during use.

6. Do not delete elements in the array.

7. Do not install uninitialized or deleted elements.

8. For an array of fixed sizes, use "array literals" to initialize

9. Assign the correct space size to the small array before use

10. Do not store non-numeric content in the numeric Array

11. Try to use a single type (monomorphic) instead of a Multi-type (polymorphic)

12. Do not use try {} catch {}

13. Avoid modifying hidden classes in Methods After Optimization

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.