Solved

does browser download completely include javascript file?

Posted on 2002-05-27
9
220 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 150 total points
Comment Utility
yes it will download the whole .js file in the user's temporary internet files folder.
0
 
LVL 33

Expert Comment

by:hongjun
Comment Utility
Include a file will download the whole. This includes all variables.


hongjun
0
 
LVL 30

Expert Comment

by:third
Comment Utility
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
 
LVL 33

Expert Comment

by:hongjun
Comment Utility
third, good illustration on the effective use of js files.

hongjun
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 30

Expert Comment

by:third
Comment Utility
thanks! ;-)
0
 
LVL 1

Author Comment

by:quanghoc
Comment Utility
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
Comment Utility
yap
comments as well.

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

hongjun
0
 
LVL 30

Expert Comment

by:third
Comment Utility
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
Comment Utility
well deserved!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now