Log In · Register

 

Help Topic Rules and Requirements

For a list of all requirements and guidelines pertaining to posting a new Help topic, please click here.

This Month's Contests | Staff Member of the Month | Hosts Looking for Hostees | Hostees looking for Hosts | BigBookofResources

Submission Guidelines

Javascript
none345678
post Feb 15 2011, 01:26 AM
Post #1


Sex, Blood, & RocknRoll
*******

Group: People Staff
Posts: 5,305
Joined: Nov 2007
Member No: 596,480



Is it better to have one big JS file or to link to them separately?
 
 
Start new topic
Replies
mipadi
post Feb 16 2011, 04:38 PM
Post #2


Senior Member
******

Group: Administrator
Posts: 2,648
Joined: Apr 2008
Member No: 639,265



Unless your site is getting something on the order of 10,000+ hits/day, it doesn't really matter.

But if you're asking purely for intellectual masturbation:

If you have one big file, your web browser will make 1 request -- but it'll have to wait for the entire file to download.
If you have a bunch of small files, your web browser can request them in parallel (to a limit -- a browser will only open a limited number of connections to a given web server).
Either way, the JavaScript files may be parsed one at a time anyway.

If you do have a really high-traffic site, you'll gain a bigger performance boost by gzip-compressing your JavaScript (and CSS) files. Also, if you're using jQuery, use Google's loader or URL to request the jQuery script, since your visitor's browser will likely already have it cached.
 
none345678
post Feb 17 2011, 12:43 AM
Post #3


Sex, Blood, & RocknRoll
*******

Group: People Staff
Posts: 5,305
Joined: Nov 2007
Member No: 596,480



QUOTE(mipadi @ Feb 16 2011, 03:38 PM) *
Unless your site is getting something on the order of 10,000+ hits/day, it doesn't really matter.

But if you're asking purely for intellectual masturbation:

If you have one big file, your web browser will make 1 request -- but it'll have to wait for the entire file to download.
If you have a bunch of small files, your web browser can request them in parallel (to a limit -- a browser will only open a limited number of connections to a given web server).
Either way, the JavaScript files may be parsed one at a time anyway.

If you do have a really high-traffic site, you'll gain a bigger performance boost by gzip-compressing your JavaScript (and CSS) files. Also, if you're using jQuery, use Google's loader or URL to request the jQuery script, since your visitor's browser will likely already have it cached.


Yeah, I was mostly asking for future reference and had general curiosity and couldn't find really a straight answer on google. Thank you kind sir.

What I am working on now is just a 1 page portfolio so I had a feeling it wouldn't matter.
 
mipadi
post Feb 21 2011, 07:32 PM
Post #4


Senior Member
******

Group: Administrator
Posts: 2,648
Joined: Apr 2008
Member No: 639,265



QUOTE(spambot @ Feb 17 2011, 12:43 AM) *
Yeah, I was mostly asking for future reference and had general curiosity and couldn't find really a straight answer on google. Thank you kind sir.


Sure.

For reference, the site I manage gets about 40,000 hits/day. That's not an extremely high volume of traffic, but the visits are very "bursty" -- sometimes we get a couple thousand hits per hour for a few hours. We have many JS and CSS files, and we just use gzip compression; on the HTML side, we use memcached to aggressively cache HTML templates and minimize database calls. It works fairly well -- we run the entire site off of a dual-core server instance.
 

Posts in this topic
spambot   Javascript   Feb 15 2011, 01:26 AM
serotonin   yea   Feb 15 2011, 02:08 AM
spambot   you so helpful   Feb 15 2011, 02:15 AM
boot   I don't think it really matters on small-scale...   Feb 15 2011, 02:38 PM
Maccabee   One big file. Fewer http requests but the differen...   Feb 15 2011, 05:09 PM
boot   QUOTE(Maccabee @ Feb 15 2011, 04:09 PM) O...   Feb 16 2011, 02:58 PM
spambot   I have something like 9 js files...which I am assu...   Feb 15 2011, 05:54 PM
mipadi   Unless your site is getting something on the order...   Feb 16 2011, 04:38 PM
spambot   QUOTE(mipadi @ Feb 16 2011, 03:38 PM) Unl...   Feb 17 2011, 12:43 AM
mipadi   QUOTE(spambot @ Feb 17 2011, 12:43 AM) Ye...   Feb 21 2011, 07:32 PM
Maccabee   Check out Yslow for firebug.   Feb 17 2011, 12:30 AM


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members: