Loading an External Script

There are two primary kinds of scripts—those that you load from an external file (in text-only format) and those that are embedded in your page (covered in the next section). It’s the same concept as external and embedded style sheets.

And just as with adding style sheets to your pages, it’s generally better to load scripts from an external file Image than to embed them in your HTML. You reap some of the same benefits, in that a single JavaScript file can be loaded by each page that needs it. You can edit one script rather than updating similar scripts in individual HTML pages.

The src attribute of the script element references ...

Get HTML5 and CSS3: Visual QuickStart Guide, Seventh Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.