O'Reilly logo

jQuery and JavaScript Phrasebook by Brad Dayley

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

Loading JavaScript from External Files

<head>   <script type="text/javascript"     src="scripts/scriptA.js"></script>   <script type="text/javascript"     src="scripts/scriptB.js"></script> </head>

As you create more and more complex JavaScript web applications, you will find that adding the JavaScript to your HTML files doesn’t make much sense. The files become too big, and you will often want to reuse the scripts in other web pages.

Instead of including the JavaScript inside the <script> tag, you can specify a src location for the script to be loaded from. When the browser encounters a src attribute in the <script> tag, it downloads the script from the server and loads it into memory.

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