Creating Portable and Modular Client-Side Scripts
March 15, 1999
|
Since the early days of browser-supported scripting, code was
simply embedded within the HTML document. Easy at first, but
this rubs against the grain of the traditional programming goal
to create modular and portable code. As scripts have grown into
ever more complex programs it becomes increasingly important to
adopt the philosophies of programming languages versus simple
markup. Several enhancements to the scripting environment help
the developer separate program code from HTML markup. This
article examines the few methods available today for
externalizing your Web scripts in attempting to keep them
modular, portable, and outside HTML. Experience with HTML markup
and embedded scripts will be useful; we'll be using JavaScript
as our de facto scripting language.
|
In the evolution of browsers from mere hypertext viewers
towards meta-operating systems we gained the ability
to process data and interaction from within the browser.
Where previously we had to rely on the Web server to execute
any instructions, the introduction of LiveScript which quickly
morphed into
JavaScript
enabled Web developers to
execute certain types of scripts on the client-side,
saving bandwidth and increasing response time. At first, script
code was simply embedded within the
HTML document, but
this rubs against the traditional aim of programming to
create modular and portable code. Several enhancements
to the scripting environment help the developer separate
program code from HTML markup; while still immature,
these techniques indeed work towards the goal of taking Web
scripting seriously. This article examines the few methods
available today for externalizing your Web scripts in
attempting to keep them modular, portable, and outside HTML.
Experience with HTML markup and embedded scripts will
be useful; we'll be using
JavaScript
as our de facto scripting language although there are
alternatives (Microsoft's
VBScript, ActiveState's
PerlScript, etc.)
Contents:
Why not embed?
|