Developing Feather-Weight Webservices with JavaScript

Introduction & purpose

This online book is generally targeted at serious web developers and those curious about JavaScript techniques for mini-applications, specifically those provided remotely; hence Featherweight Web Services with JavaScript. Along the way we cover two extremely useful techniques for programming in JavaScript:

  1. Passing arguments to remote scripts via the src attribute of <script> tags. Chapter: Passing JavaScript arguments via the src attribute.
  2. Including and reusing code libraries while maintaining the simplest possible client code; ie, a single <script></script> call to load many script files. Chapter: Using JS code libraries.

Skipping around is a time honored tradition for technical manuals and the web especially. We encourage you to read the manual in order to get the most of it. The techniques and discussions generally build upon each other throughout.

This is a living manual and shall be edited, updated, amended, or rearranged over time. See Major changes and errata for important update notes.

Ethics

JavaScript can be be used unethically and has a reputation for it. Some users will not even enable it in their browsers because of this. Ironically, the biggest security holes it exploits are usually the result of poor coding in other languages like PHP and Perl; read more about cross-site scripting at Wikipedia.

Please take the high road and code carefully. The continuing adoption of this service model depends on it.

What you’ll need for this manual

JavaScript is an often underestimated, direct and simple programming language. Though it is not really related to Java, its syntax is largely similar. Anyone who knows Perl, Java, C, or any other modern language should have little difficulty following JavaScript.

The manual tries to cover topics thoroughly but does assume programming ability in the reader. Newcomers to JavaScript or those without some skill in another language will have trouble with many of the examples and techniques presented.

An understanding of HTML or XHTML, and CSS is necessary for the kinds of services that we can reasonably build with JavaScript. Hyper text markup languages and their cousins are simple and can be learned from scratch in a few hours from good tutorials. W3 Schools has many.

We believe this book introduces a valuable—and obvious but heretofore unknown—technique for passing arguments to remote scripts; Passing JavaScript arguments via the src attribute. In Object orientating and prototypes, we cover a powerful way to transparently manage classes and code library reuse which also seems widely unknown.

While these chapters are not the entire purpose of the manual, they are certainly the parts you are unlikely to see elsewhere and may be best reason to read this.

What we have specifically avoided

There is no code in this manual that relies on browser detection. It’s valuable to know but a distraction and space filler. Very little browser specific code is presented. Where it appears, it is noted.

Some browsers not tested against at all

How this manual is structured

There is a preface section, which includes this page, the main manual, which progresses from the basic technique for simplistic scripts to more elaborate ways to handle things that can rightly be called services. There is an appendix with various references, extended notes, and sample code.

There a Table of Content. The contents of the site may be searched with the Google search box at the bottom of each page.

Live or practical examples of code are used whenever possible.

Lasting lessons

What you should know when you’re done

We hope you will have picked up some interesting, new, and robust JavaScript techniques as well as some good style pointers. JavaScript is often looked down upon because it’s so easy to use that it can be coded very messily. You should be able to see that even simple languages with limited scope like client-side JavaScript can be wielded in powerful and unexpected ways.

There are some powerful and somewhat advanced techniques presented. If you absorb them, you’ll be able to write your own JavaScript classes, extend the built in ones, and import any of this new code into scripts transparently. Finally, you should be ready to tackle your own featherweight web services limited only by your imagination.

« Contents · Example services in this manual »
Google
 
Web Developing Featherweight Web Services with JavaScript
This is version 0.57b of this manual. It is a beta version with some gaps. We are grateful for feedback.

The code is the manual has not yet been fully tested against Internet Explorer. Bug reports are welcome.
An Elektrum Press Online