473,395 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Too many (small) vs. too large linked script files in a document...

Just wondering if anyone have looked into this?

How to split up ones JavaScript library?
A lot of very specific (and small) .js files, or
a few larger files.

I'm thinking about load-time here...

I have a gut-feeling that it will be better to use
(a lot of ) smaller (very specific) files, giving you
a much better granularity...

Any thoughts?
Have someone benchmarked this?
Am I way too far down in my wine bottle?
Do you care?

;-)

--
Dag.

Jul 23 '05 #1
4 2495
Dag Sunde wrote:
Just wondering if anyone have looked into this?

How to split up ones JavaScript library?
A lot of very specific (and small) .js files, or
a few larger files.

I'm thinking about load-time here...

I have a gut-feeling that it will be better to use
(a lot of ) smaller (very specific) files, giving you
a much better granularity...

Any thoughts?
Have someone benchmarked this?
Am I way too far down in my wine bottle?
Do you care?

;-)


This is so easy to test - it probably takes longer to write the
question.

Loading 30 script files from local drive took 468ms, loading one file
that contained all the content of the 30 files took 16ms.

Is *anyone* surprised that reading 30 references, requesting 30 files,
opening, reading, parsing, closing, etc. is slower than reading one
reference, requesting one file... you know the rest.

Anyone who has tried to transfer lots of files over a network knows it
is much, much faster to make one big file, send it, then unpack it at
the other end - ever heard of CPIO or its friend, SCPIO? Is UNIX
really that dead? Or has Linux changed the name to something presumably
more sexy but nonetheless awfully geeky?

Damn, that wine bottle is really on empty, eh? ;-p

--
Rob
Jul 23 '05 #2
"RobG" <rg***@iinet.net.auau> wrote in message
news:4I******************@news.optus.net.au...
Anyone who has tried to transfer lots of files over a network knows it is much, much faster to make one big file, send it, then unpack it at the other end - ever heard of CPIO or its friend, SCPIO? Is UNIX
really that dead? Or has Linux changed the name to something presumably more sexy but nonetheless awfully geeky?


Anyone who has downloaded content from a Web site knows it's much faster
to let the browser do GET requests on several images at once then it is
to do a GET, wait for an image to download, do another GET, let that
image download, etc.

By putting all your JavaScript in one large file, it must download
synchronously.

By splitting it into several small files, the browser can perform up to
4 GETs (HTTP 1.0) or 2 GETs (HTTP 1.1) simultaneously.

Anyone who has ever FTPed several large files over the Internet will
have also seen this. For example, when I FTP FreeBSD ISOs, I get
approximately 60-80Kb/s on each of the 4 downloads. As downloads end and
I have one left, that ISO downloads at approximately 100Kb/s, not the
240-320Kb/s you might expect.

When it comes to the Internet, one large pipe is not the same as several
smaller ones.

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #3
Grant Wagner wrote:
[...]
By putting all your JavaScript in one large file, it must download
synchronously.

By splitting it into several small files, the browser can perform up to
4 GETs (HTTP 1.0) or 2 GETs (HTTP 1.1) simultaneously.

Anyone who has ever FTPed several large files over the Internet will
have also seen this. For example, when I FTP FreeBSD ISOs, I get
approximately 60-80Kb/s on each of the 4 downloads. As downloads end and
I have one left, that ISO downloads at approximately 100Kb/s, not the
240-320Kb/s you might expect.
Next time my browser tries to download 4 JavaScript files of 300KB each
then maybe I'll remember your advice.

A JS file of 300 lines is perhaps 11KB. The overhead of doing the GET
is likely more than the effort to download the file, so better to
download one 11KB file than say four of 3KB each.

You also assume that the browser is only downloading the JS files - it
probably isn't. The other streams are probably downloading other page
content, so why use them for JS when they may be better employed
getting images or other content?
When it comes to the Internet, one large pipe is not the same as several
smaller ones.


Quite true, but it can't be claimed that lots of small files is
*always* better than one (or a smaller number of) bigger file(s).

I'll bet there are some frustrated network engineers lurking who could
argue this one for weeks on end...
--
Rob
Jul 23 '05 #4
JRS: In article <A7**************@news2.mts.net>, dated Thu, 16 Dec
2004 16:57:04, seen in news:comp.lang.javascript, Grant Wagner
<gw*****@agricoreunited.com> posted :

By splitting it into several small files, the browser can perform up to
4 GETs (HTTP 1.0) or 2 GETs (HTTP 1.1) simultaneously.


But be aware that that can be very annoying for users with limited
bandwidth who are trying to load a big page in the background of doing
other work, perhaps interactive.

An author should not presume that his work is all that is of interest to
his readers.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Chris Smith | last post by:
'Morning, Within the next few months, I'm going to embark upon a comparatively rather large base of JavaScript code to be called from a web browser environment. Not too awfully huge, but...
1
by: bayouprophet | last post by:
Cant get menu script to to put linked page in the same frame. I am new to Java and I am wondering what am I doing wrong? below are my java applet file, frame.html file, and my text file and one...
2
by: marco.avidano | last post by:
I'm asking: for the PHP parser, it's better to create one large file with all the code inside or a lot of small files? Can a large file slow down the execution of the script?
3
by: Michel de Becdelièvre | last post by:
I have some *performance* trouble reading MathML files in my application (in ASP.Net). - I have small MathML files (2-3k) as input - as (almost) all MathML files these use entities. I have no...
6
by: Greg | last post by:
I am working on a project that will have about 500,000 records in an XML document. This document will need to be queried with XPath, and records will need to be updated. I was thinking about...
3
by: Tony Lugg | last post by:
I have an application with a document management form. When users add documents to the form, I call the API function SHGetFileInfo to get the associated large and small icons for the file. These...
2
by: lawrence k | last post by:
I've a file upload script on my site. I just now used it to upload a small text document (10k). Everything worked fine. Then I tried to upload a 5.3 meg Quicktime video. Didn't work. I've...
25
by: tekctrl | last post by:
Anyone: I have a simple MSAccess DB which was created from an old ASCII flatfile. It works fine except for something that just started happening. I'll enter info in a record, save the record,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.