When you are working with code, such as JavaScript, most of it is included in the file you’re working on. But this isn’t always the best way to work. A large site can have several files that contain the same JavaScript functions. But what if you need to update this code? You would need to update it on every single page, which is both time-consuming and error-prone. You can eliminate this problem by linking to a file that contains all your common code in one place.
In this way you gain consistency and the ability to quickly make changes to your entire site. The Phireworx site links to a file called common.js, which contains the JavaScript code and functions we want to run on every page. The more you can break your site into manageable modular segments, the easier it is to implement changes.
By linking scripts into the document, in addition to the maintainability issues they enable, they also speed up download times, since the script only has to be downloaded once, rather than on every single page that uses them.
_________________
M.Rilwan