O'Reilly logo

HTML5 24-Hour Trainer by Mark Fletcher, Joseph W. Lowery

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 22. Advanced JavaScript

In the previous lesson, you got your first look at JavaScript and how it integrates with HTML on a basic level. JavaScript is a very robust language made even more valuable in recent years by enhancements to the JavaScript engines incorporated in modern browsers. Now JavaScript functions execute faster than ever — which has lead to an explosion of development particularly in the area of JavaScript code libraries, also known as frameworks.

There's an amazing wealth of freely available JavaScript functionality already developed in these frameworks that you can apply to your websites — all you need to know is how. In this lesson you learn how to work with one of the most popular JavaScript frameworks, jQuery, and integrate its code into your own starting with the key step of linking to external JavaScript files.

LINKING EXTERNAL FILES

Just like external CSS files are the best approach to styling an entire website, consolidating your JavaScript functions in one or more external documents is the preeminent method for adding enhanced functionality. To externalize your JavaScript, you'll need two elements: a page of JavaScript functions and a <script> tag linking to that page from your source code.

Creating a JavaScript file is very straightforward and can be accomplished with any text editor. In essence, you simply move any JavaScript functions from your main page, whether located in the <head> or <body> sections, to a blank text file. You must move only the ...

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