Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 230
  • Last Modified:

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
0
quanghoc
Asked:
quanghoc
  • 4
  • 4
1 Solution
 
thirdCommented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now