Brajeshwar
Brajeshwar

Reputation: 1520

Stacking CSS files instead of combining them - Pros & Cons?

If you look at the source of The Boston Globe, you'll see that one single link strings together all the CSS in one go.

<link href="/css/html5reset.css,globe-globals.css,globe-masthead.css,globe-nav.css,globe-nav-menus.css,globe-saved.css,globe-main.css,globe-footer.css,globe-print.css" rel="stylesheet" media="only all">

I'm seeing this for the first time. My Questions

  1. Is this a good way of including CSS?
  2. Does it makes just one HTTP call? (The source shows them as one single CSS file when clicked).

Upvotes: 3

Views: 173

Answers (2)

archil
archil

Reputation: 39501

In production environment, it's good practice to make as few http requests as possible. The number of requests may affect performance more than the size of content itself as browsers typically limit the number of concurrent HTTP connections, so multiple of them may be in pending state before others finish. And the example makes single http request to specified url, and there should be some kind of handler on server side that concatenates requested css files into one, and sends it back as response.

Upvotes: 2

Quentin
Quentin

Reputation: 944565

you'll see that one single link strings together all the CSS in one go

No. What we see is a single file with a URL that implies it has been created by concatenating together a bunch of files.

Is this a good way of including CSS?

Yes. Having a single CSS file means having a single HTTP request to fetch it.

Does it makes just one HTTP call?

Yes.

Upvotes: 3

Related Questions