Jump to content

Recommended Posts

I'm just wondering, I did Google the matter and there was information saying it both ways, a lot of smaller files means more HTTP requests but large files require more packets for data transmission which takes longer.

I assume that they're both the same when it comes to caching?

I've also heard about gzipping the files which apparently speeds up requests but it doesn't work universally?

And for my final question, is it the same when it comes to CSS?

One file is pretty ideal, but it isn't ideal to jumble everything into one file just because of that... idealistic approach.

 

For instance.. you wouldn't want 1000 functions in one file that handle everything from image preloading to AJAX to jQuery to IP configurations, etcetera...

 

Simplification is the key.  It's not about many files you can keep from creating.  Unless you're looking into security by obfuscation or something.

My take:

 

Have separate files for "categories" of JavaScript functions. For example, I will have function for form processing in one file and only load that file on the pages with forms.

 

You should definitely develop using separate files, but when you deploy, as salathe said, it depends on the situation. If you have a number of files that appear on every page on your site, and don't change much independently of each other, then there's no harm in compiling them together for deployment. Even better if you use something like Google's closure compiler, or YUI Compressor

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.