I am curious to know if any research has been conducted regarding the
efficiency of having a single (large) .js file downloaded for a
webpage compared to several smaller .js files.
For example in my web pages I often include the scripting code
<script language="javas cript" type="text/javascript"
src="ascript.js "></script>
which contains all the code for a given function, i.e. the main
function and any subsidiary functions.
I have developed a few library functions (leftString, rightString,
etc.) and these can be invoked by functions in other .js files, so I
would have something like
<script language="javas cript" ... src="libs.js"></script>
<script language="javas cript" ... src="ascript.js "></script>
I'm just wondering if there is any difference in download time when
the HTML has to download these separate .js files rather than a single
one.
Even though the use of broadband is spreading I still like to keep my
web pages as efficient as possible, not everyone has broadband after
all, some still use dial-up connections.
Does anybody know? 3 1445
Gargoyle <no****@loadsar ubbish.perswrot e:
I'm just wondering if there is any difference in download time when
the HTML has to download these separate .js files rather than a single
one.
Even though the use of broadband is spreading I still like to keep my
web pages as efficient as possible, not everyone has broadband after
all, some still use dial-up connections.
Does anybody know?
If you have a lot of small js files then each one will require a separate
request. On a slow link the overhead associated with each request may
become significant.
On the other hand, if you need to change one of your js files then any
browser which has your page in cache will be able to serve up the
unmodified scripts from cache and only the edited one needs to be
downloaded. So if you have a file or files which change frequently load it
separately.
Also, imagine page A requires files W, X and Y and page B needs X, Y and Z:
If you combine each page's javascript then A gets WXY and B gets XYZ which
would be two separate large javascript files. Or you could combine all
possible Javascript for your site and the first page gets the even larger
WXYZ but the second page hit gets it from cache. That way the people who
hit only one page on your site lose out, but if they hit both pages they
gain. Or you could combine XY and keep W and Z separate but then you have a
maintenance headache constantly tuning your site every time a page's
requirements change.
In other words there is no simple answer. Use a tool such as Firebug or
Fiddler to see what your pages are actually doing.
On 9 Jul 2007 12:42:38 GMT, Duncan Booth
<du**********@i nvalid.invalidw rote:
>Gargoyle <no****@loadsar ubbish.perswrot e:
>I'm just wondering if there is any difference in download time when the HTML has to download these separate .js files rather than a single one.
Even though the use of broadband is spreading I still like to keep my web pages as efficient as possible, not everyone has broadband after all, some still use dial-up connections.
Does anybody know?
If you have a lot of small js files then each one will require a separate request. On a slow link the overhead associated with each request may become significant.
On the other hand, if you need to change one of your js files then any browser which has your page in cache will be able to serve up the unmodified scripts from cache and only the edited one needs to be downloaded. So if you have a file or files which change frequently load it separately.
Also, imagine page A requires files W, X and Y and page B needs X, Y and Z:
If you combine each page's javascript then A gets WXY and B gets XYZ which would be two separate large javascript files. Or you could combine all possible Javascript for your site and the first page gets the even larger WXYZ but the second page hit gets it from cache. That way the people who hit only one page on your site lose out, but if they hit both pages they gain. Or you could combine XY and keep W and Z separate but then you have a maintenance headache constantly tuning your site every time a page's requirements change.
In other words there is no simple answer. Use a tool such as Firebug or Fiddler to see what your pages are actually doing.
Thanks for the info Duncan.
In the meantime I've done a few crude tests downloading a page with
three scripts over a DUN connection. I thought one of my script files
was fairly large and yet it only took 2 seconds to download. I guess 2
seconds is reasonable. With a bit of tinkering I could probably get it
down to 1 second.
Gargoyle wrote:
On 9 Jul 2007 12:42:38 GMT, Duncan Booth
<du**********@i nvalid.invalidw rote:
>Gargoyle <no****@loadsar ubbish.perswrot e:
>>I'm just wondering if there is any difference in download time when the HTML has to download these separate .js files rather than a single one.
Even though the use of broadband is spreading I still like to keep my web pages as efficient as possible, not everyone has broadband after all, some still use dial-up connections.
Does anybody know?
If you have a lot of small js files then each one will require a separate request. On a slow link the overhead associated with each request may become significant.
On the other hand, if you need to change one of your js files then any browser which has your page in cache will be able to serve up the unmodified scripts from cache and only the edited one needs to be downloaded. So if you have a file or files which change frequently load it separately.
Also, imagine page A requires files W, X and Y and page B needs X, Y and Z:
If you combine each page's javascript then A gets WXY and B gets XYZ which would be two separate large javascript files. Or you could combine all possible Javascript for your site and the first page gets the even larger WXYZ but the second page hit gets it from cache. That way the people who hit only one page on your site lose out, but if they hit both pages they gain. Or you could combine XY and keep W and Z separate but then you have a maintenance headache constantly tuning your site every time a page's requirements change.
In other words there is no simple answer. Use a tool such as Firebug or Fiddler to see what your pages are actually doing.
Thanks for the info Duncan.
In the meantime I've done a few crude tests downloading a page with
three scripts over a DUN connection. I thought one of my script files
was fairly large and yet it only took 2 seconds to download. I guess 2
seconds is reasonable. With a bit of tinkering I could probably get it
down to 1 second.
Strip out the unnecessary comments, (keep them in a source file
elsewhere) and make EVERYTHING that is used twice, a function....
Size is all that really matters with download speed, above a few hundred
ms anyway. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Peter Williams |
last post by:
Hello All,
I'm a newbie to this ng. I'm posting here because I have a question
about debugging some javascript on some pages of my website. Please
don't call me a "troll" -- because I'm not one. :-)))
The next page is called "basic_snake" and creates a message which
follows the cursor. Up until today, I used this type of message
attached to the mouse pointer for the following pages on my website:
index.html, delphi.html &...
|
by: Lennart Björk |
last post by:
Hi All,
I have a tiny program:
<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>MyTitle</title>
<meta http-equiv="Content-Type" content="text/html;
|
by: comp.lang.php |
last post by:
I have a form that when you click the "Generate Report" submit button,
it will force download a CSV file, required for this project.
On the very same page you also have a "Search" submit button, when you
press it it should generate search results in a new page.
However, when you click the "Generate Report" submit button, the moment
you try to THEN click the "Search" submit button, the "Search" submit
button NEVER goes to a new page but...
|
by: extrudedaluminiu |
last post by:
Hi,
Is there any group in the manner of the C++ Boost group that works on
the evolution of the C language? Or is there any group that performs an
equivalent function?
Thanks,
-vs
|
by: Brett Kelly |
last post by:
Ok, I know this sounds odd. Let me explain further.
I have an ASP.net page (w/ C# code behind) that, when given a session
variable containing the path to a local file, will attempt to start the
download of that file for the user.
Here's the content of my Page_Load:
protected void Page_Load(object sender, EventArgs e)
{
| |
by: Chuck Renner |
last post by:
Please help!
This MIGHT even be a bug in PHP!
I'll provide version numbers and site specific information (browser, OS,
and kernel versions) if others cannot reproduce this problem.
I'm running into some PHP behavior that I do not understand in PHP 5.1.2.
I need to parse the HTML from the following carefully constructed URI:
|
by: rn5a |
last post by:
I have a HTML page named Index.html which is divided into 3 frames. The
URL of 2 of the frames are HTML pages but the 3rd frame houses a ASP
page.
Now when I go to Windows Explorer, navigate to the folder in which the
all the 4 files (3 HTML + 1 ASP) reside & select Index.html (by
clicking with the mouse or by using the arrow keys on the keyboard),
strangely the Windows "File Download" dialog box (with 'Open', 'Save',
'Cancel', 'More...
|
by: Chrisjc |
last post by:
I was told the other day that I was able to place HTML in my database.. So I thought to my self that be grate for my feature points so I can use bullets... so I put the following code in one of my COL's just to see if it work here is the following code.
<ul>
<li>Pro-GUARD 7 high flow, high efficiency filter media air filter</li>
<li>Increases horsepower up to 100 HP depending on application</li>
<li>Improves torque up to 112 lbs/ft...
|
by: OldBirdman |
last post by:
Efficiency
I've never stumbled on any discussion of efficiency of various methods of coding, although I have found posts on various forums where individuals were concerned with efficiency. I'm not concerned when dealing with user typing, but I am if a procedure is called by a query.
Does the VBA compiler generate "in-line" code for some apparent function calls? For example, y = Abs(x) might be compiled as y = x & mask. The string...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |