Using a JavaScript include file has several advantages compared to directly
embedding JavaScript code inside a script block. The main advantage is that it
provides code reuse by keeping the code in a central place. Another advantage is
that your page size will be reduced significantly causing the page to be easier to
maintain. Probably the most important advantage is caching by the browser.
Subsequent requests to your page will retrieve the JavaScript library from the
browser cache in order to load a lot faster.


You can place your JavaScript code in a “.js” file, and include it in your web pages using the following syntax:



<script src="KaramasoftUtility.js" type="text/javascript"></script>