As Technical Director for SitePoint, Kevin Yank keeps abreast of all that is new and exciting in web technology. Best known for his book, Build Your Own Database Driven Website Using PHP & MySQL, now in its third edition, Kevin also writes the SitePoint Tech Times, a free, biweekly email newsletter that goes out to over 150,000 subscribers worldwide.
When he isnt speaking at a conference or visiting friends and family in Canada, Kevin lives in Melbourne, Australia, and enjoys performing improvised comedy theater with Impro Melbourne, and flying light aircraft. His personal blog is Yes, Im Canadian.
About Cameron Adams
Cameron Adams melds a background in Computer Science with almost a decades experience in graphic design, resulting in a unique approach to interface design. He uses these skills to play with the intersection between design and code, always striving to create interesting and innovative sites and applications.
Having worked with large corporations, government departments, nonprofit organizations, and tiny startups, he's starting to get the gist of this Internet thing. In addition to the projects that pay his electricity bills, Cameron muses about web design on his well-respected weblogThe Man in Blueand has written several books on topics ranging from JavaScript to CSS and design.
Sometimes hes in Melbourne, other times he likes to fly around the world to talk about design and programming with other friendly geeks. If you ever see him standing at a bar, buy him a Baileys and say hi.
About SitePoint
SitePoint specializes in publishing fun, practical, and easy-to-understand content for web professionals. Visit http://www.sitepoint.com/ to access our books, newsletters, articles, and community forums.
Preface
On the surface, JavaScript is a simple programming language that lets you make changes to your web pages on the fly, while theyre being displayed in a web browser. How hard could that be to learn, right? It sounds like something you could knock over in an afternoon.
But JavaScript is bigger on the inside than it seems from the outside. If you were a Dr. Who fan, you might call it the TARDIS of programming languages. If youre not a Dr. Who fan, roll your eyes with me as the fanboys (and girls) geek out.
Everyone back with me? Put your Daleks away, Jimmy.
As I was saying, JavaScript sounds like it should be simple. Nevertheless, throughout its ten year history (so far), the best ways of doing things with JavaScript have seemed to change with the seasons. And advice on how to write good JavaScript can be found everywhere: Do it this wayitll run faster! Use this codeitll run on more browsers! Stay away from that featureit causes memory leaks!
Too many other JavaScript bookssome of them from very respected names in the industrywill teach you a handful of simple solutions to simple problems and then call it a day, leaving you with just enough rope with which to hang yourself when you actually try to solve a real-world problem on your own. And when in desperation you go looking on the Web for an example that does what you need it to, youll likely be unable to make sense of the JavaScript code you find, because the book you bought didnt cover many of the truly useful features of the language, such as object literals, event listeners, or closures.
This book aims to be different. From the very first page, well show you the right way to use JavaScript. By working through fully fleshed-out examples that are ready to be plugged right into a professionally-designed web site, youll gain the confidence not only to write JavaScript code of your own, but to understand code that was written by others, and even to spot harmful, old-fashioned code thats more trouble than its worth!
Throughout this book, weve tried to go the extra mile by giving you more than just the basics. In particular, weve covered some of the new JavaScript-powered development techniqueslike Ajaxthat are changing the face of the Web. Weve also included sections that explore the new crop of JavaScript libraries like jQuery, Prototype, Yahoo! UI, and Dojo, making this the only beginners JavaScript book to cover these powerful time-savers.
all of which made this book a lot harder to write, but thats why they pay us the big bucks.
Who Should Read this Book?
Whether youve never seen a line of JavaScript code in your life, or youve seen one too many lines that doesnt do what you expect, this book will show you how to make JavaScript work for you.
We assume going in that youve got a good handle on web design with HyperText Markup Language (HTML) and Cascading Style Sheets (CSS). You neednt be an expert in these languages, but as well see, JavaScript is just another piece in the puzzle. The better you understand basic web design techniques, the more you can enhance them with JavaScript.
If you need a refresher, we highly recommend