What Do You Mean, "Web Savvy?"
If you have written HTML and CSS, but JavaScript has always scared you a little, this book is for you.
If you know enough to put some jQuery plugins on a page, but not enough to fix them when something goes wrong, this book is for you.
And if you have learned JavaScript in a casual way, but you're intimidated by the sudden outpouring of technologies around it--Node.js! Backbone! Grunt!--and want to understand it in a more disciplined fashion, this book is for you.
Teaching at Seattle Central Community College, many of my students have a little bit of web experience, but they're not programmers. Maybe they call themselves "web designers," and their experience has been mostly in HTML and CSS, or they're on the development track but they've never done any real coding before. Either way, they (and, I believe, a large number of other interested would-be students) are ill-served by the vast majority of JavaScript books, which are either long on theory and short on practical context, or are aimed at more experienced programmers.
This book aims to address that audience. If you know your way around a <body> tag but you've never written your own JavaScript from scratch, you can be considered "web-savvy": you've got the background, you just need some guidance and a helping hand. I'm writing this book for my class of developers and designers, but I hope you'll find it useful as well.
What This Book Will Teach You
- Best JavaScript practices: By the time you finish this book, you'll have a good foundation for continuing your JavaScript education. You won't be an industrial-strength web programmer, but you'll be prepared to take next steps, and I'll try not to leave you with bad habits that you'll have to unlearn later.
- Practical scripting skills: You will learn how to build real-world interaction patterns, such as slideshows, galleries, forms, and menus.
- Modern techniques for new and old browsers: You'll learn how to write code that works well in old browsers, and works better in the newest clients. You'll also learn how to use JavaScript to improve your HTML and CSS, and vice versa.
- Real-world tooling and workflow: From the start, this book will teach you to develop using the same powerful tools used by professional web developers on the cutting edge. There are no toy environments here.
What This Book Won't Teach You
- HTML and CSS: For this book, I assume that you have a basic understanding of how web pages are built and loaded in the browser.
- Old-school browser hacking: Unlike a lot of books, we'll go straight into jQuery, skipping the low-level DOM functions. You should learn those eventually, but they're badly-designed and awkward--not a good place to start.
- "Recipes" for your code: My goal is to teach you good programming habits, not magic formulas that you can copy and paste for a given task.
Crucially, this book is not a comprehensive guide to JavaScript and jQuery. One of the most important skills you'll need as a programmer is the ability to read and absorb technical documentation, such a the Mozilla Developer Network or the jQuery API docs. It's always better to use those first-hand sources for information, rather than relying on a paraphrase that might be out of date, since the technology of the web moves very quickly.
That said, there's plenty of misinformation out there on the web. So throughout the book, you'll find plenty of links to articles, documentation, and further reading to fill in the gaps. There are also intermittent chapters ("intermissions") that cover topics outside of strict JavaScript coding, such as source control, project architecture, and good HTML best practices. Finally, at the end, I'll recommend some resources that can guide you as you continue forward on your JavaScript career.
Why JavaScript?
Since it was invented in 1995, JavaScript has undergone a transformation that's been nothing short of astonishing. Originally conceived as a simple way to add simple interactions to web pages, it has since powered the shift toward web applications that can rival desktop programs. With the introduction of Node.js, it has spawned a remarkable new set of development tools and processes on the desktop. And it has introduced millions of new coders to techniques like closures and functional programming.
I'm not sure that JavaScript is a good language--it has a collection of serious flaws, many of which date back to its hasty creation--but I do think it's a fun language. JavaScript can be expressive, even whimsical. It doesn't hurt that it's possibly the best cross-platform programming language ever created, since wherever there is a web browser, you'll find JavaScript. And in an increasingly web-powered world, we find browsers everywhere: in your phone, on your TV, and embedded in many of your favorite non-web applications (the company where I work, ArenaNet, uses a version of Google's Chrome to power many of its in-game interfaces for its flagship title, Guild Wars 2). You can build serious software in JavaScript, and many people are doing so.
I also believe JavaScript provides us with a unique opportunity. Like the BASIC code I played with as a kid, JavaScript puts the ability to program right at your fingertips, for free, and without any gatekeepers or restrictions. On the web, you can write whatever software you want, without worries about cost of entry or being censored from an app store. As our world is powered more and more by code, that's a deeply-important freedom to have. Learning to write for the open web platform has been one of the most fulfilling and useful skills I've ever learned. I hope, by the end of this book, you'll agree.
About Me
Like a lot of web developers, I'm not formally trained in computer science. I was originally a journalist in Washington, DC, where I ran the multimedia team at Congressional Quarterly, using JavaScript and other languages to help the newsroom report on politics and government. In 2011, I moved to Seattle, where data journalism jobs are thin on the ground, and transitioned into doing straight-up web development for a living. You can see examples of my work, from writing to data visualization to software, at ThomasWilburn.net.