This is a note about Javascript Performance, by reading the amazing book High Performance JavaScript by Nicholas C. Zakas, which helps developers to identify problem and providing better solution, to improve execution time, downloading, interaction with the DOM, page life cycle, and more.
Data Access
Concepts such as the scope chain and prototype chain can affect your overall script performance.
DOM Scripting
DOM interaction is slower than other parts of JavaScript, how repaint and reflow can slow down your code.
Algorithms and Flow Control
Loops and recursion can work against you when it comes to runtime performance.
Strings and Regular Expressions
Poor string-handling performance in browsers, work around methods is explained
Responsive Interfaces
User experience, several techniques is discussed to ensure that the user interface remains responsive at all times.
Ajax
Different data formats can affect Ajax performance and why XMLHttpRequest
isn’t always the best choice.
Remark
Evolution of JS
- JavaScript was first introduced as part of Netscape Navigator in 1996
- Google introduced their brand-new browser called Chrome in 2008.
- The V8 JavaScript engine is a just-in-time (JIT), which produces machine code from JavaScript code and then executes it.
Things affect JS
- Delays caused by network latency and operations, affecting the appearance on browser
- Simple optimizations such as function inlining, code folding, and string concatenation algorithms are easily optimized in compilers, it solves only part of the performance problem.
Original goal of JS
- JS is originally designed for form validation
- JS is originally designed for functionality directly in the page