Chapter 21. Adding JavaScript

The modern Web is built on three technologies: HTML, CSS, and JavaScript. The first provides content and structure, the second provides presentation, and the third provides interactivity and advanced applications. JavaScript is a client-side — meaning it runs on your computer, not the web host — scripting language. Because JavaScript is not compiled, like Java or C++, all you need to write and read it is a text editor, just like HTML and CSS.

JavaScript is enjoying a bit of a renaissance these days, especially with the upcoming release of HTML5. The major browsers have all revamped their JavaScript engines with a focus on faster processing. HTML5 provides support for many JavaScript enhancements affecting user interactivity, databases, local storage, offline applications, geolocation, audio and video manipulation, and even drawing with the new <canvas> tag.

A comprehensive examination of all that JavaScript can do is far beyond the scope of this book, but this section of the book can get you started. For any work in JavaScript on the Web, you need to know how to include JavaScript in your web page both as directly as code and also by referencing an external script. In this lesson, you learn how to add JavaScript code to your page, how to prepare for website visitors who have JavaScript disabled, and how to test your JavaScript.

UNDERSTANDING JAVASCRIPT

JavaScript can address aspects of the browser used to look at a web page as well as the web page itself. ...

Get HTML5 24-Hour Trainer 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.