Solved

does browser download completely include javascript file?

Posted on 2002-05-27
9
225 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
9 Comments
 
LVL 30

Accepted Solution

by:
third earned 150 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
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!

 
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP: Filling Out/Creating a PDF 29 160
PHP Web Development 6 64
setInterval() calls function twice in one interval 2 50
Keyup listener getting fired on initial page load 1 49
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

739 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