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
LVL 1
quanghocAsked:
Who is Participating?
 
thirdConnect With a Mentor Commented:
yes it will download the whole .js file in the user's temporary internet files folder.
0
 
hongjunCommented:
Include a file will download the whole. This includes all variables.


hongjun
0
 
thirdCommented:
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">
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
hongjunCommented:
third, good illustration on the effective use of js files.

hongjun
0
 
thirdCommented:
thanks! ;-)
0
 
quanghocAuthor Commented:
So basically, the whole thing will be downloaded, including "comments" ?? What if the .js file has included another .js file?
0
 
hongjunCommented:
yap
comments as well.

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

hongjun
0
 
thirdCommented:
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! ;-)
0
 
hongjunCommented:
well deserved!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.