Chapter 8. JavaScript and Ajax

Introduction

JavaScript is a prototype-based scripting language with syntax that’s loosely based on the C programming language. It’s closely related to ECMAScript, which is standardized by Ecma International as outlined in the ECMA-262 specification. In web applications, JavaScript is used to add dynamic functionality to static pages or to lighten the load on server-side processing by letting the user’s browser do some of the work.

JavaScript’s widespread adoption has always been dependant on how various web browsers have chosen to implement (or in some cases, ignore) various features of the language. JavaScript developers who have been around for a while will remember looking at browser compliance charts when deciding whether or not adding some JavaScript dynamism would sacrifice the portability of their web application. Luckily this situation has changed for the better; for whatever reason, browser vendors are no longer trying to gain market share by designing quirks into their software. Developers can now use JavaScript liberally in their web applications and be confident that most users will experience these features consistently.

There are still differences in the way the major browsers deal with specific JavaScript implementations, but fortunately there is a solution. A number of JavaScript helper libraries have emerged during the past few years that take the pain out of tasks such as browser version detection and compliance checks. These ...

Get Rails Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.