Accelerated DOM Scripting with AJAX, APIs, and Libraries

Reviewed October 23rd, 2007 @ 08:21AM

[Book Cover] Accelerated DOM Scripting with AJAX, APIs, and Libraries

Accelerated DOM Scripting, Ajax, APIs, and Libraries by Jonathan Snook, Aaron Gustafson, Stuart Langridge, and Dan Webb is not just another book on DOM scripting. There are many excellent DOM scripting and JavaScript books available to us as developers. Some are thorough explanations of JavaScript with a little bit about the DOM, while others are full blown books on the subject of DOM scripting. This book takes a slightly different direction discussing DOM scripting in light of Ajax, the array of APIs available, and the many libraries available that help us rapidly develop our applications. Upon hearing of the arrival of this book, I was worried that it might be something that would be considered obsolete the week after it was published due to the rapid rate of change in libraries and APIs. After reading this book, that worry was put to rest as each of the authors did an excellent job of digging into the guts of the libraries, exposing how things are done, how you could do it yourself, and how a library could be of assistance to you.


Chapter 1 starts us off with an explanation of the state of JavaScript. JavaScript has been abused heavily in the past, and due to this abuse and its inconsistencies - many developers chose to shy away. However, this is no longer the case. Along with explaining the state of JavaScript, we get to look at ways to manage our JavaScript code as well as debug our code. This gives us the tools we need as we begin development throughout the rest of the chapters.

Chapter 2 dives into HTML, CSS, and JavaScript. Often referred to as the trinity of front-end development, it is valuable for you to understand the purpose of each, and how they interact with one another. The basics of each are discussed, and then we move to the DOM and find out how we can use semantic markup and meaningful CSS to create the necessary hooks for our JavaScript to interact. Topics such as traversing, reading, and writing to the DOM, handling attributes, detecting browser support, and handling events are all discussed. This chapter builds from previous chapter, and prepares us as we move on to the following chapters.

Chapter 3 tackles the sometimes tough subject of object oriented programming. Depending on your background and experience in programming, the idea of OOP may seem foreign to you. However, the author does an incredible job of highlighting the benefits, formatting, and examples throughout the entire chapter. Some of the benefits discussed are: Namespaces, closures, and encapsulation. To me, this chapter was one of the most valuable in the entire book as it helps you to understand the programming at the core of the libraries that are discussed. Knowing what is going on under the hood is extremely important as you develop and troubleshoot your code.

Chapter 4 moves us to the discussion of the available libraries. As I stated earlier, I was concerned that this book would quickly become stale due to the change and development of libraries. I couldn't have been more wrong. This chapter doesn't just show you the libraries and move on. This chapter teaches you how the libraries work, how you can develop within the libraries, and explains the benefits of using libraries. It teaches you what takes place under the hood for so many different aspects. Along with teaching these things, the author gives you some tips as you are searching and selecting a JavaScript library to work with, something invaluable as there are many options to choose from.

Chapter 5 moves into the world of Ajax and Data Exchange. This chapter discusses all of the nuances of Ajax. These are the important things that need to be addressed before you start implementing Ajax in your applications. Understanding the data formats that are returned. Understanding the HTTP codes. Understanding the different ActiveX Objects. Understanding how to prepare for and handle failure. All of these things are very important as you use Ajax. After you learn what is going on under the hood and how to put the pieces together, the author shows you how libraries can help you in the process.

Chapter 6 discusses Animation, what most people think of when they hear Ajax. As with the previous chapter, you start off by building a simple animation object, then look to see what the libraries have to offer.

Chapter 7 takes us into form validation with JavaScript. All validation should first take place on the server side, then use the client-side to enhance the user experience. The tricky part comes when you find yourself maintaining two validation codebases, one in a server-side language and one in JavaScript. This chapter brings both of these worlds together and allows you to specify your validation rules in one place, sharing your server-side code with the client-side. This makes the validation process much easier and expandable. If you ever want to add or remove validation rules, you can do it in one spot and both the server-side and client-side will follow suit. As with the previous chapters, we first build our example from scratch so we understand the core, then we see how libraries can help us in the process.

Chapter 8 is a case study in building a FAQ system. This chapter walks through the process of creating a usable, accessible, and progressively enhanced FAQ system. This case study builds the semantic HTML, the necessary CSS hooks, and uses the necessary JavaScript to achieve our tasks. The process is extremely thorough as each and every piece is tackled and dissected in the building process. This case study is an excellent tutorial in using all of the building blocks we have discussed up to this point.

Chapter 9 is another case study that walks us through the process of building a dynamic help system. This current example utilizes the Ruby on Rails framework to build the application. The first part of this case study spends important time in planning and preparation. This is important in any application that uses progressive enhancement. As the author points out, this chapter starts with a solid base of semantic HTML, and then builds the CSS and JavaScript on top where necessary. The planning is in place, the foundation is established, and the hooks are in place. As with the previous case study, this chapter does an excellent job of diving in and showing you all of the little details necessary to put an application together.


This book went beyond my initial expectations. It is geared more towards someone who already has a good understanding of HTML, CSS, and JavaScript. If you are looking for a book to teach you JavaScript, then this is not it. This book will help you take your understanding of JavaScript to the next level, and help you grasp what is going on at the core of your library of choice. This is especially important when you have to troubleshoot a piece of JavaScript, or you have to extend something to fit your needs. This book doesn't simply leave you with an explanation of libraries, but teaches you where libraries are helpful, and how you can fully understand what the libraries have to offer. JavaScript is not evil. JavaScript libraries are not evil. This book will show you how to make proper use of the tools available to you.