Learning to Use Jquery to Build Better Websites, Though Examples and Popular Plug-Ins.
Learning jQuery 1.3 aims to teach the reader a bit of everything that this popular JavaScript library offers and provide a guide to some of the more useful plug-ins available for it. It starts by taking the reader through some basic examples of how to add jQuery to a web-page before a series of chapters explaining different parts of the library and then a series of projects. The contents of the book could be summed up as: What is jQuery, what can you do with it? And how do you do it?
Readers already familiar with jQuery might be wondering how quickly this book was put together, considering the version in the title was only released this past January. However jQuery has been in testing for several months, and since author Karl Swedberg is a member of the jQuery Project Team, so it’s a safe bet he had some idea what was coming in 1.3, like the new .live() binding options covered in one of the break-out boxes that dot the book.
What is jQuery?
Older web developers remember what JavaScript development was like before 2005 when most developers were using JavaScript for things like form-validation, and any kind of visual effects was best left to Flash. When Prototype (from where jQuery borrowed the $()-syntax) and script.aculo.us arrived with Ruby of Rails, it was the start of a re-birth for JavaScript. Prototype put the ability to manipulate the web page in reach of the average developer.
John Resig was inspired by Prototype to create his library in 2006 that took the idea of manipulating the page further; with jQuery, HTML was just the raw structure waiting to be “queried” and moulded with JavaScript. It became easy to attach JavaScript functions to page elements so that adding validation to a form could be as easy as the web designer adding a specific CSS class to an HTML tag. Instead of the old way of mixing HTML and JavaScript into each other, the HTML could remain clean and readable to human or DreamWeaver alike, and the additional functionality sat waiting in a “$(document).ready(” at the end of the page.
What can you do with it?
JQuery excels at finding elements in the page and then acting on them. I remember seeing an example, written with and without jQuery, that observed all the external links in an HTML page and added an icon before them- with jQuery half a page of JavaScript shrunk down to 3-4 lines. Learning jQuery devotes the first set of chapters to showing how properly using jQuery’s handling of selectors, events, animation and Ajax can achieve some powerful things in a fraction of the space pure JavaScript would take. If anything is missing, I didn’t see much coverage of optimizing your code. For instance, jQuery’s selection engine can do some powerful searches, but it is still written in JavaScript so it might have been good to have some tips here. By the end of the first set of chapters, readers should have a good idea though of how to use jQuery’s core functions.
How do you do it?
After these chapters comes a set on how to manipulate tables, forms and adding dynamic elements to a page (shufflers and rotators), these are quite in-depth and show the authors have a range of knowledge of how to use jQuery effectively. The last two chapters cover plug-ins– both how to write them and some of the more useful ones out there, including a brief introduction to the jQuery UI library.
The appendix includes a good set of tutorials, including one on JavaScript closures. Some readers might not be aware of the familiar “$(document).ready(function() {…})” syntax is a closure should be mindful of some of the issues involving this JavaScript language feature.
Conclusion:
Like may Packt books, layouts are clean, functional with a few graphics, break-out boxes to illustrate important points (like the new .live() /.die() enhancements to .bind() methods). The book follows the format of the show the reader how to get started, what can be done with the base library and then show what else is out there. After the contents, preface book has a guide to what is covered in the chapters, wish more books had this. The book’s chapters cover the basics (getting started, selectors, events, effects), the more complicated ( DOM manipulation, AJAX, Table manipulation) and finally forms, shufflers and rotators, and the plug-ins: using plug-ins (including recommended ones), writing your own. Finally, there are some on-line resources, development tools, a bit on JavaScript closures and a quick-reference.