high performance javascript

"High Performance JavaScript "

 

1.      The original purpose of javascript was to improve the experience of web users, and early javascript saved a lot of time for Internet users.

2.      The growth of javascript code, IE6 's javascript engine cannot bear it, because of its "static garbage collection mechanism", javascript developers and web applications are developing, but IE6 's javascript engine has not developed.

3.      Google's chrome was the firstbrowser to use an optimized javascript engine.

4.      Loading and execution: Every time the <script> tag appears, the page waits for the parsing and execution of the script, and the downloading and rendering of the page must stop and wait for the script to execute. (Placing the script at the top of the page will delay the loading of the page - > put it at the bottom + reducethe number of <script> s in the page + do not put the inline script after the <link> )

5.      Non-blocking loading method: load the script after the page is loaded

6.      Four basic data of Javascript : direct quantity, variable, array element, object member. The deeper an identifier is located, the slower it is to read and write -- > local variables are the fastest to read and write, and global variables the slowest. If a cross-scope value is referenced more than once in a function, it should be stored in a local variable.

7.      The more times the DOM is accessed

8.      For ... in loops are slower than while , for , do ... while . switch is faster than if ... else when the number of conditions is high. Optimizing if ... else Purpose: Minimize the number of comparisons needed to reach the correct branch. Put the most likely one first;inline if ... else as if ... else

9.      Ajax is the foundation of high-performance javascript . Make pages load faster by delaying the download of bulky resource files. Asynchronously transmit data on the client side and the server side. Is to significantly improve the user and website interaction experience.

10.  Performance testing tool: YUI Profiler

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326948291&siteId=291194637