Web Development with jQuery®

(Elliott) #1

Programming Conventions (^) ❘ 17


FIGURE 1-2


Here are the problems with this approach:


➤ (^) If JavaScript is disabled, viewing the larger picture doesn’t work.
➤ (^) JavaScript can be disabled out of personal preference.
➤ (^) JavaScript can be disabled because of company policy.
➤ (^) Placing the JavaScript directly in the markup document adds unnecessary bloat and complex-
ity to the markup document.
The overwhelming point in all this is that inline JavaScript is a bad way to approach adding comple-
mentary, interactive functionality to a web document.
Here is a better approach to the application presented in Figure 1-2. First, take the inline JavaScript
out of the markup and replace it with a reference to an externally loaded JavaScript. The following
example names the externally loaded JavaScript Example 1-3.js:
<!DOCTYPE HTML>




content="application/xhtml+xml; charset=utf-8" />

Pumpkin Head






[http://www.it-ebooks.info](http://www.it-ebooks.info)

Free download pdf