Link to home
Start Free TrialLog in
Avatar of quanghoc
quanghoc

asked on

does browser download completely include javascript file?

If I put this in a html file:
<script language="javascript" src="file.js">
 Will the browser download the whole .js file? Or it just download the only functions that are called in html file? The matter is that I have a .js file with a lot of functions as a library but not every html page is using all functions. Just need to know if this will waste downloading time. Thanks
ASKER CERTIFIED SOLUTION
Avatar of third
third
Flag of Philippines image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Include a file will download the whole. This includes all variables.


hongjun
if it's really huge then i guess it's advisable to put the common functions used into one .js file and call this in each of your pages. the other functions should reside to other individual .js file. only the pages that needs this function should reference the .js file.

so for example a page needs the common functions file and the specific functions file you can add two extenal .js file to your page.

<script language="javascript" src="file.js">
<script language="javascript" src="specific.js">
third, good illustration on the effective use of js files.

hongjun
thanks! ;-)
Avatar of quanghoc
quanghoc

ASKER

So basically, the whole thing will be downloaded, including "comments" ?? What if the .js file has included another .js file?
yap
comments as well.

js file include another js file?
how you do that!!!

hongjun
add info:

.js files cannot include another .js file. if you want to include two separate .js files on the web page, do what i have illustrated above.

thanks for the A! ;-)
well deserved!