Solved

does browser download completely include javascript file?

Posted on 2002-05-27
9
224 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
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

Technology Partners: 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!

Question has a verified solution.

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

Suggested Solutions

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
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 tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

685 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