473,785 Members | 2,720 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2515
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.ne t.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*****@agrico reunited.com>
comp.lang.javas cript 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.ne t>, dated Thu, 16 Dec
2004 16:57:04, seen in news:comp.lang. javascript, Grant Wagner
<gw*****@agrico reunited.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.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.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
1918
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 probably between 10K and 15K LoC. Having seen only the kinds of scripts that support interactive web pages, I'm dreading trying to stretch JavaScript that far. Has anyone here done something like this, and want to share some experience? In my...
1
3255
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 of my link file that should load next to the menu on the same page. And Thank You in advance. Here is my menu applet: <html>
2
2683
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
2568
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 way to restrict the entities used. - to read an XML file entities into a document, you need to use a DTD, or you get an exception (any other way ?) - The MathML DTD is HUGE (2400+ Entities, ~300k of files), loading it in a document is a big CPU...
6
2657
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 splitting up the XML into several XML documents (perhaps 50,000 per document) to be more efficient but this will make things a lot more complex because the searching needs to go accross all 500,000 records. Can anyone point me to some best practices...
3
2758
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 icons are added to two ImageList objects which are bound to a ListView control, and everything looks great. I am saving the icons to a SQL Server table by using Icon.Save to a stream and assigning the byte array to the field, then loading them...
2
552
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 set the POST limit in php.ini to 8 megs. What reasons, other than the POST limit, would a large upload fail?
25
20567
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, and try to move to another record and get an Access error "Record is too large". The record is only half filled, with many empty fields. If I remove the added data or delete some older data, then it saves ok and works fine again. Whenever I'm...
0
9480
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,...
0
10319
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, 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...
0
10147
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8971
agi2029
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...
1
7496
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5380
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...
1
4046
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
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.