High Performance JavaScript |
Author: Nicholas C. Zakas
Author: Nicholas C. Zakas This is a slim book on how to write efficient Javascript. Most of the advice it gives is well known to Javascript experts but it could be better known by every Javascript programmer. Many of the chapters the introduce and discuss the ideas in depth could really be reduced to a single recommendation or at most a set of bullet point of do and don'ts. The fact that things are explained in so much detail might irritate some users but personally I enjoyed reading about the inner workings of the language. Chapter 1 deals with the well known and standard problem of maximising Javascript load speeds and avoiding blocking the browser. From here we move to optimising access to variables and in-memory data in general. Then on to DOM scripting, what makes DOM access fast and how to avoid updating the DOM with small fragments of code. Chapter 4 is a fairly conventional look at optimising the flow of control - which loop is fastest type of discussion. Chapter 5 is about strings and regular expression and given that most Javascript spends a lot of time on strings this is valuable. Chapter 6 takes us inside the browser to look at the way Javascript interacts with its UI thread. The basic idea is to yield every now and again to let the UI thread attend to other things by the use of timers. Next we have the inevitable chapter on Ajax which takes the form of an introduction to Ajax with a few comments on caching and a list of best practices. Chapter 8 deals with to sorts of optimisations that you would find appropriate to almost any language and the final two chapter round up with a look at building and deploying Javascript apps and Tools that you can use as part of optimisation. There is nothing truly new in this book but it is nice to have it all collected together in one place. At the end of the day however, apart from non-blocking and optimised downloading of scripts, I'm not convinced that you need to be too obsessive about optimisation. Most of the time the differences are slight - unless the problem code is in a loop which multiplies any inefficiencies by the number of times it loops. This isn't a book for the beginner and it isn't for you if you don't want to have the ideas explained to you. You can learn a lot about Javascript from the details of how the performance enhancements work - but if you just want a list of best practices this might seem like a lot of work to get to the punch line. With these slight reservations the book is still highly recommended.
|
|||
Last Updated ( Friday, 06 January 2012 ) |