Flames Posted May 27, 2010 Share Posted May 27, 2010 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? Quote Link to comment Share on other sites More sharing options...
salathe Posted May 27, 2010 Share Posted May 27, 2010 Yes. I don't know, have you? Yes. Oh and for which is better, both; it depends. Quote Link to comment Share on other sites More sharing options...
Zane Posted May 27, 2010 Share Posted May 27, 2010 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. Quote Link to comment Share on other sites More sharing options...
Psycho Posted May 27, 2010 Share Posted May 27, 2010 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. Quote Link to comment Share on other sites More sharing options...
spambadger Posted May 28, 2010 Share Posted May 28, 2010 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.