CSS and JavaScript: More Files or Less?
Thursday, July 3rd, 2008If you do much reading about web optimization, you will have heard people say that you should cram all your CSS into a single large file, and all the JavaScript into another, in order to save on loading times.
80% of the end-user response time is spent on the front-end. Most of this time is tied up in downloading all the components in the page: images, stylesheets, scripts, Flash, etc. Reducing the number of components in turn reduces the number of HTTP requests required to render the page. This is the key to faster pages. (Yahoo Developer Network)
In other places, you will be told that you should separate your CSS into multiple files to make it easier to manage. One for layout, one for typography, one for colors…
Which do you think is a better idea? Personally, I prefer quick loading times. Your users will thank you for faster pages; they don’t care if it’s easy to edit parts of your site or not. Generally I prefer to put all of the main CSS into one file, but on pages that require a large amount of unique styles, I include a separate file with the page-specific styles.



This is yet another web-related topic that gets people arguing. Not quite as bad as “Mac vs. PC,” it really gets some people going. Which is better, a fixed-width layout, or a fluid one that resizes to fit the browser window. Unlike some people, I say that it depends on the project, and that there isn’t a one-size-fits-all solution (though I do lean slightly toward fixed-width layouts). Besides, if we all agreed on standards for everything, we wouldn’t have anything to argue about..







