O'Reilly logo

Smashing Html5 by Bill Sanders

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 12: Adding Just Enough JavaScript

JavaScript is a Web programming language that you can use with HTML5. It can be used to access certain parts of your Web pages written in HTML5 and do other things that simply cannot be done without JavaScript. This chapter introduces some basic features that are going to be used specifically with HTML5 elements.

JavaScript is considered a scripting language because it’s interpreted by the browser at runtime (when you actually open a Web page) rather than compiled and stored on your computer as a binary file. Slightly different versions of JavaScript can creep in with different implementations of the

language on different browsers. Because JavaScript meets an ECMAScript standard (ECMA-262), these differences are slight, and what I’ll be discussing in this chapter are only those aspects of JavaScript that you can use with HTML5.

Finally, JavaScript and Java have nothing in common — JavaScript is not based on an interpreted version of Java. They could be named dogs and cats or apples and oranges for all they have in common. The name with java in it sounded better. So, if you want to look up something on the Web about JavaScript, you won’t be helped if you just look for Java.

Inserting JavaScript into HTML5 Pages

JavaScript programs are placed in the head of a Web page because that part of the Web page loads first, so it’s ready when the rest of the page loads. They act very much like CSS3 scripts, and like CSS3 scripts, they can be placed ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required