How To Import Javascripts on Pages

I had a serious problem with some Javascript functions and I found that there is some way to import the scripts in your pages. And each one will act different than another one.


GNU Logo

GNU Logo

‪Title : How To Import Javascripts on Pages

‪Publish Date : 02/22/2010

‪Version : 1.0

‪Author : Nasser Hajloo

‪Author Mail :

‪Copyright (c) 2010 Nasser Hajloo.

‪Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation;

‪with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled “GNU Free Documentation License”.


As you all know Javascript is Script language which used in web pages to do some client activities. In addition is a Server side Language which control users behavior on server and get necessary feedback to him/her.

With this background we understand that Javascript will do some thing on client, And there is two way to use javascripts code in pages. Classic Asp ( .Net 1.0 ) used a bad scenario to work with scripts, It imports scripts insode of Asp page and every peace of script codes in every postback comes from server to client and it cause to increase page size. In this scenario all JS files putted on a HTM/HTML page and this page imported on Classic Asp page.


<!--#include virtual="JS.htm" -->

The <!–#include virtual=”JS.htm” –> is server side include, won’t work without certain configurations and is included by the server there and then already whereas javascript’s way is loaded into the page. Server Side Includes (SSI) is a simple interpreted server-side scripting language used almost exclusively for the web. (You can get more info at Wikipedia )

The above code increase page size and end-user may got crazy. So there should be a good solution to reduce the page size. use another approach to use scripts.

In Pages Java script codes has a JS file template. And you can write your codes inside it, Then you can ipmort it in your page and when page downloads to users computer, JS files are downloading in users computer Temp directory.

This approach will reduce page size and let page load much faster than classic Asp pages. So to do this, all you need is addresssing JS file in your Pages.


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


The above code will download MyJavaScript.JS file tousers Temp Directory and every pages which address it, will use this file. So you address every where anddownload just one file to users computer.