| If you want to learn about JavaScript from scratch—what it is, what to use it for, and how to make it work with other technologies like CSS and HTML—you have picked up the right book. If you already have a considerable amount of experience with JavaScript, but want to bring your knowledge up to date, you have also picked up the right book—a lot has changed in JavaScript development in recent years.
When JavaScript first started being used for web development back in the mid-to-late 1990s (it was first supported in Netscape 2, back in 1996), it quickly became much maligned, for many reasons—browser support was mediocre at best, and at worst, you actually had different JavaScript functions being implemented in different ways by different browsers (Netscape 4 and Internet Explorer 4 were major culprits, at the height of the so-called browser wars). This led to developers having to write completely different versions of web sites or indulge in messy code forking, if they wanted to attempt to have cross-browser support.
And that was the consciencious ones—JavaScript’s bad reputation was just as much the fault of the developers as the browser manufacturers. Developers back in those days tended to use JavaScript for all manner of flashy effects that looked cool, but caused all manner of problems in terms of usability and accessibility (the days of DHTML—another marketing buzzword back in the day, which referred to the application of JavaScript, CSS, and HTML to produce dynamic effects). Pages would break completely if JavaScript was unavailable for any reason or if the user was trying to use a screenreader. And a lot of web developers would copy and paste scripts into their web sites without understanding how they actually worked, causing more untold usability and code maintenance nightmares.
But as I said earlier, things have changed. Browser support is now at a manageable level, with the modern browsers largely using the same implementation of the Document Object Model and other constructs, and modern techniques are a lot more considerate of accessibility, etc. As you’ll learn through the course of this book, modern techniques like DOM scripting are built around the premise of separating out not only the structure (in your markup) and the presentation (in your CSS), but also the behavior in your JavaScript files (not interspersed through your markup documents). JavaScript does not have to be evil—you can code your web sites so that the JavaScript enhancements you are using can add to the experience of users who can take advantage of them, but they don’t break when JavaScript is not available. This is called unobtrusive JavaScript—JavaScript enhancements should be seen as a bonus for those who can use them, not an essential feature for the running of a site.
If you’ve used JavaScript before, then be prepared to take on a new mindset as you step forward through the book. If you are completely new to JavaScript, then breathe a sign of relief and consider yourself lucky that you never had to suffer the early days of JavaScript development that I just touched on! |