Home  >  Article  >  Web Front-end  >  High Performance JavaScript (High Performance JavaScript) reading note analysis_javascript skills

High Performance JavaScript (High Performance JavaScript) reading note analysis_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:07:05823browse
Chapter 1: Loading and Execution

The browser’s JavaScript engine is a compiler layer optimization;
When the browser executes JavaScript code, it cannot do anything else at the same time ( Single process), which means that every time the <script> tag appears, it will overbearingly let the page and other scripts be parsed and executed (each file must wait until the previous file is downloaded and executed before it starts downloading), so the JS and CSS is used to render the page, and JS for interactive behaviors (almost all) is placed at the bottom of <body>; <BR> all major browsers allow parallel downloading of JS. <BR>Reducing the number of external link scripts will improve performance (merging JS) <BR>Any website can use a URL that combines the specified files to obtain any number of files. <BR>The defer attribute can defer scripts (only supported by IE4 and FF3.5) <BR><STRONG>Chapter 2: Data Access <br><br>There are four basic data access locations in JavaScript: Direct quantities, variables, array elements (indexed by numbers), object members (indexed by character beds). <BR>Accessing direct quantities and local variables is the fastest. On the contrary, accessing array elements and object members is relatively slow. <BR>The deeper a property or method is in the prototype chain, the slower it is to access it. <BR>Generally speaking, JavaScript performance can be improved by saving commonly used objects, array elements, and cross-variables in local variables. <BR><STRONG>Chapter 3: DOM Programming <br><br>DOM operations are faster in webkit-based browsers, while other browsers execute innerHTML faster. <BR>Accessing and manipulating DOM is an important part of modern WEB applications. But every time you cross the bridge linking the two islands of ECMAScript and DOM, you will be charged a 'bridge toll'. <BR>Be aware of re-entry and rearrangement. <BR>In IE:hover will reduce the response speed. <BR><STRONG>Chapter 4: Algorithms and Process Control <BR><BR>Avoid using for-in loops unless you need to traverse an object with a number of attributes. <BR>Learn about stack overflow errors. <BR><STRONG>Chapter 5: Strings and Regular Expressions <br><br>Backtracking is both a fundamental component of regular expression matching functionality and a source of regular expression inefficiency. <BR><STRONG>Chapter 6: Responsive User Interface <br><br>No JavaScript task should take more than 100 milliseconds to execute. <BR>Web workers are a feature supported by new browsers. <BR>No JavaScript code is important enough to affect the user experience. <BR><STRONG>Chapter 7: Ajax <br><br>JSON is a lightweight data format with fast parsing speed. <BR>Reduce the number of requests by merging JS and CSS, as well as IMG. <BR>Shorten page loading time. After the main content of the page is loaded, use Ajax to obtain those secondary files. <BR><STRONG>Chapter 8: Programming Practice <br><br>Most of the time, there is no need to use eval() and Function(), so it is best to avoid using them. As for setTimeout() and setInterval(), it is recommended to pass in a function instead of a string as the first parameter. <BR>There are many ways to create objects and arrays in JavaScript, but using object and array literals is the fastest way (the more object properties and array items there are, the more obvious the benefits of using literals). <BR>Don’t duplicate work: lazy loading; conditional preloading. <BR>Use native methods more because they are faster. <BR><STRONG>Chapter 9: Build and deploy high-performance JavaScript applications <br><br>PV (page view) is page views or clicks. <BR>Reduce the number of HTTP requests required to render a page, especially for those users visiting the site for the first time. <BR>JavaScript compression. <BR>JavaScript caching. <BR>Using Content Delivery Network (CDN) <BR>Chapter 10 mainly introduces tools: such as firebug, YSlow, and some performance analysis.</script>
Statement:
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