JavaScript Intensive tutorial--javascript performance optimization

Source: Internet
Author: User

This article ish5eduAgency officialHTML5 Trainingtutorials, the main introduction:JavaScript Intensive Tutorials--Data access

the location of data access also affects the speed of JavaScript, so let's summarize the most reasonable and efficient way to run JavaScript if you can allocate access locations .
The data access location is divided into 1. Literals (such as true, false, NULL, and so on) 2. Local variables (var a=5;) 3. Array elements (Var arr=[]; arr[0]=5;) 4. Object Members
all of these can store data
based on the time required to read data 200 000 times in different browsers, from fast to slow to 1 2 3 4 (combined, different browsers will have a float)

quick and efficient execution of JavaScript code summary:
1. Access literals, local variables are faster than array elements and object members.
2. Because local variables are in the starting position of the scope chain, accessing local variables is faster than accessing cross-domain variables. The deeper the variable's position in the scope chain, the slower the access, and the slowest the access because the global variable is always at the end of the scope chain.
3. Nested object members can significantly affect performance and are used sparingly.
4. The deeper the property or method is in the prototype chain, the slower the access speed.
5. In general, you can promote JavaScript performance by storing array elements, object members, and cross-domain variables in local variables, because accessing local variables is faster
6. Use with as little as possible, because he will change the execution of the environment scope chain, the same Type-catch statement in the sub-statement catch also has the same effect, so be careful.
with the above release, you can significantly improve the real-world performance of a large number of Web applications that use JavaScript.

Click to enter JS Intensive tutorial

This article is from the "11721999" blog, please be sure to keep this source http://11731999.blog.51cto.com/11721999/1834187

JavaScript Intensive tutorial--javascript performance optimization

Related Article

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.