Betsy Waliszewski caught up with Jerry recently and asked him a few
questions about his eagerly awaited new book.
- Waliszewski:
What's significant about JavaScript, and why should Web developers
be using it?
- Bradenbaugh:
JavaScript is the de facto standard of scripting languages
on the Internet. Using JavaScript to enhance page design and user
interactivity is a staple for ensuring that Web sites and applications are
feature-rich and consistent for users with virtually any major browser.
- Waliszewski:
With all the JavaScript books available, what makes yours stand out?
- Bradenbaugh:
Most books focus on JavaScript syntax for reference or for getting
started with JavaScript. Some of the more advanced books provide basic to
intermediate JavaScript applications.
JavaScript
Application Cookbook takes that a step further by providing users
larger, ready-to-use applications that address common Web site needs such
as a client-side search engine, online test administration, cookies-based
user profiles, and more.
- Waliszewski:
So, this is full of JavaScript applications?
- Bradenbaugh:
Instead of just handing the readers a book of applications, each chapter
goes through an application, often line by line, so readers can learn how the
applications work and how to extend and customize them.
- Waliszewski:
How does DHTML fit into these chapters?
- Bradenbaugh:
JavaScript plays an integral part in DHTML, so readers will definitely see
it in there. To keep the focus on JavaScript, however, most of the
applications and discussions shy away from incorporating rich visual effects
capable of stylesheets and proprietary extensions such as MSIE's filters and
transitions.
- Waliszewski:
How did you go about choosing which applications to cover for the book?
- Bradenbaugh:
The majority of applications came as a result of profiling dozens of
Web sites. In addition, I looked for tools that met business challenges, such
as site searching, user profiles, shopping, attracting visitors, sending email, and getting online help.
Also, I receive a lot of email from my JavaScript Web site,
HotSyte--The JavaScript
Resource. Most of the messages are from coders asking for help.
Many of the requests are for similar features such as searching, form
validation, and cookies. If lots of coders want the same thing, an
application is born.
- Waliszewski:
What if readers want to extend the applications?
- Bradenbaugh:
The chapter discussions and syntax make it easy for users to understand
how and where to make changes in the code.
- Waliszewski:
O'Reilly's definition of a cookbook is a book that helps you "cook up
code." Is there a lot of code in
JavaScript
Application Cookbook?
- Bradenbaugh:
Yes and no. Yes, in that readers can expect to encounter hundreds of
lines of JavaScript and HTML. No, in that I've made an attempt to economize
the applications by reusing code from one chapter to another. In many cases,
readers will only have to examine the code once. Barring minor
application-specific changes, they'll be able to recognize and understand the
same code in other chapters almost immediately.
- Waliszewski:
What are 5 things that a potential JavaScripter should know before
beginning?
- Bradenbaugh:
Anyone interested in adding JavaScript to his or her skillset should be
familiar with the following:
- HTML Syntax
- General awareness of differences in browsers, such as Netscape Navigator
and Microsoft Internet Explorer
- Knowledge of what JavaScript can and can't do
- General knowledge of JavaScript's role with the document object model
(DOM)
- General knowledge of cascading stylesheets
- Waliszewski:
What makes using JavaScript so easy?
- Bradenbaugh:
JavaScript is easy for a number of reasons:
- It is embedded in HTML pages
- JavaScript is an interpreted language (essentially, coders can make
changes to their JavaScript and view them immediately)
- The syntax is easy to learn
- The Web is crammed with JavaScript resources
- Waliszewski:
Why is it important to have a JavaScript strategy before building an
application?
- Bradenbaugh:
There are at least a couple of reasons. First, applications, even the
small ones, tend to change or become larger. Managing code for larger and more
complex applications can quickly become unruly, especially when making
modifications that affect multiple pages. Sometimes functionality can be
affected simply by moving the application from one machine to another.
Implementing a JavaScript strategy allows programmers to better manage
these applications when such changes occur.
Also, many of the applications that JavaScript (and virtually all other)
programmers build are based on smaller tasks that have been repeated over
and over in previous applications. Examples include form validation, reading
cookies, and enabling image rollovers. Designing these "pieces" of the
application with the 10,000-foot perspective enables coders to reuse these
pieces of trusted code instead of rewriting new JavaScript every time an
HTML form pops up.
- Waliszewski:
What kinds of obstacles might someone encounter in the application-building
process?
- Bradenbaugh:
One of the largest obstacles to overcome in JavaScript application
building is accommodating multiple browsers. Cross-browser scripting is
almost an industry in itself. This book guides readers through the basic
steps of code modifications for differences in Microsoft Internet Explorer
and Netscape Navigator.
Though becoming less of an obstacle, coders can run into browsers of varying
JavaScript capabilitiies. JavaScript 1.0-capable browsers can't run
JavaScript 1.2 code, for example. Readers will learn how to adopt a strategy
for handling browsers of lesser JavaScript capability.
Another obstacle coders can run into is scope creep. Scope creep is the
process of continually adding features to or changing features of an
application during its development. It's often enticing to add that "quick
extra feature" to make an application better. Unfortunately, this can dilute
the focus of the original application features. JavaScript coders can fall
under the same influence.
- Waliszewski:
Can you tell me a little about the "shopping bag" and the product
search feature?
- Bradenbaugh:
Shopping Bag allows Webmasters to easily add online shopping to their Web
site. All their product adds, changes, and deletes can be performed from a
single file. As an added feature, that same lone file acts as a database so
shoppers can search for products and prices. What's more, it's all
JavaScript; no server-side scripting is necessary until the shopper submits
the order.
- Waliszewski:
What's next on the horizon for you now that you've finished
JavaScript
Application Cookbook?
- Bradenbaugh:
Next? I thought I was all done! Actually, I'm currently pursuing other
ways to incorporate JavaScript. JavaScript can be extremely powerful when
generated by a server-side scripting language. I'm also researching the
growing number of JavaScript extensions such as incorporating it in Flash
presentations, Acrobat forms, and even running it from the command-line.
The list keeps growing.