JavaScript and Danger-Driven Development

"In JavaScript, there is a beautiful, elegant, highly expressive language that is buried under a steaming pile of good intentions and blunders."

                                                      –  Douglas Crockford, JavaScript: The Good Parts

This quotation expresses essentially what optimizing JavaScript code is all about.

Often fascinated by the latest shiny feature or by the need to deliberately or pretentiously display his own abilities, the developer's mind sometimes slips into a mysterious state of awaken sleep by which he is overcome by the need to show off overly complex code or by the desire to use the most recent features even though he knows, deep down, that this means that he will have to sacrifice long-term stability and the efficiency of his computer program. This way of building applications is what we might call "Danger-Driven Development". JavaScript has many very bad parts but has enough good parts to outweigh the bad ones. This being said, the problem with Danger-Driven Development is the fact that the developer listens to the sirens of JavaScript's awful parts at the expense of the end user’s satisfaction.

In this chapter, we will cover a few of JavaScript’s best and worst parts, especially those that pertain to code efficiency and overall performance, and how a developer should always write safe, reliable and highly efficient JavaScript code even if doing so is not as enchanting as coding the latest shiny.

Thus, we will cover the following points:

  • The global object and local variables
  • Avoiding bad idioms and keeping an eye on the very bad parts
  • Using the DOM efficiently
  • Structuring and loading a JavaScript application
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset