RavenJeGames
RavenJeGames

Reputation: 153

Multiple css file with one http request

I'm new to Web development so sorry if this question may seem obvious.

I would like to separate my css files in precise categories.

But I know that doing so, and importing them with pure css, will cause multiple http requests, slowing down the page loading.

I know that something is possible with a language called Sass. Thing is, I would like to avoid it, and try to fix this using only css standard.

Is it even possible? Or sass and other things like it are the only solution?

Thanks!

Upvotes: 1

Views: 510

Answers (1)

Quentin
Quentin

Reputation: 943561

You cannot achieve this with plain CSS.

  • If you want to fetch all the CSS with one HTTP request, then all the CSS needs to be in one file.
  • If you want to write your CSS in separate files, then they won't be.

You can use a tool which will combine those files into a single file. SASS is one such tool (and one which is very popular, well tested, and abundant in other features). You can write a single file which @imports the CSS files (which, IIRC, will requires .scss file extensions) and otherwise not use any SASS features at all.

You could use other tools instead (such as cat).

Upvotes: 2

Related Questions