1

Is it possible to add multiple css in header tag with one http request to execute all css file at once ?

I know about

@import url('/css/typography.css');
@import url('/css/layout.css');
@import url('/css/color.css');

can we do something like or any other solution to reduce http requests

<link rel='stylesheet' href='/css/typography.css,layout.css,color.css'>
1
  • If minimizing http request is really necessary for you, then try merging the css files (if they are related and and it is possible). Commented Aug 16, 2013 at 8:16

4 Answers 4

1

No but you can club all your style sheets into one sheet and import that like so:

<link rel='stylesheet' href='/css/main.css'>
Sign up to request clarification or add additional context in comments.

Comments

0

Bundle your CSS files for production and minify ofc.

http://www.sitepoint.com/faster-page-loads-bundle-your-css-and-javascript/

1 Comment

0

Yes, you can use ASP.NET MVC bundling and minification feature. You create a bundle like this:

bundles.Add(new StyleBundle("~/Content/customcss").Include(
      "~/Content/css/typography.css",
      "~/Content/css/layout.css",
      "~/Content/css/color.css"));

And you can render it like this (in a Razor View):

@Styles.Render("~/Content/customcss")

In Release compilation mode, your bundles will be automatically merged and minified, but you can set the flag manually in Debug mode as well:

BundleTable.EnableOptimizations = true;

See this for reference.

Comments

0

yes you can? with apache/nginx MODPAGESPEED https://www.modpagespeed.com/

<head>
<link rel="stylesheet" type="text/css" href="styles/yellow.css">
<link rel="stylesheet" type="text/css" href="styles/blue.css">
<link rel="stylesheet" type="text/css" href="styles/big.css">
<link rel="stylesheet" type="text/css" href="styles/bold.css">
</head>

can become

<head>
<link rel="stylesheet" type="text/css" href="styles/yellow.css+blue.css+big.css+bold.css.pagespeed.cc.xo4He3_gYf.css">
</head>

Disclaimer: Apache PageSpeed is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the Apache Incubator.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.