Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

does browser download completely include javascript file?

Posted on 2002-05-27
9
Medium Priority
?
228 Views
Last Modified: 2013-11-18
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
0
Comment
Question by:quanghoc
  • 4
  • 4
9 Comments
 
LVL 30

Accepted Solution

by:
third earned 600 total points
ID: 7038003
yes it will download the whole .js file in the user's temporary internet files folder.
0
 
LVL 33

Expert Comment

by:hongjun
ID: 7038009
Include a file will download the whole. This includes all variables.


hongjun
0
 
LVL 30

Expert Comment

by:third
ID: 7038015
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 33

Expert Comment

by:hongjun
ID: 7038018
third, good illustration on the effective use of js files.

hongjun
0
 
LVL 30

Expert Comment

by:third
ID: 7038024
thanks! ;-)
0
 
LVL 1

Author Comment

by:quanghoc
ID: 7038107
So basically, the whole thing will be downloaded, including "comments" ?? What if the .js file has included another .js file?
0
 
LVL 33

Expert Comment

by:hongjun
ID: 7038126
yap
comments as well.

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

hongjun
0
 
LVL 30

Expert Comment

by:third
ID: 7038174
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
 
LVL 33

Expert Comment

by:hongjun
ID: 7038329
well deserved!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This article discusses how to implement server side field validation and display customized error messages to the client.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question