Should I aim for fewer HTTP requests or more cacheable CSS files?
Posted
by Jonathan Hanson
on Stack Overflow
See other posts from Stack Overflow
or by Jonathan Hanson
Published on 2010-04-21T18:25:06Z
Indexed on
2010/04/21
18:33 UTC
Read the original article
Hit count: 238
We're being told that fewer HTTP requests per page load is a Good Thing. The extreme form of that for CSS would be to have a single, unique CSS file per page, with any shared site-wide styles duplicated in each file.
But there's a trade off there. If you have separate shared global CSS files, they can be cached once when the front page is loaded and then re-used on multiple pages, thereby reducing the necessary size of the page-specific CSS files.
So which is better in real-world practice? Shorter CSS files through multiple discrete CSS files that are cacheable, or fewer HTTP requests through fewer-but-larger CSS files?
© Stack Overflow or respective owner