1

I read Googles Optimize CSS Delivery article but I still don't know how much I can put in an inline style block. Google recommends using inline css when the content is small and for big files they suggest linking to a css file.

When I have css with about 250 lines, is it appropriate for inline css or should I link to it?

1

2 Answers 2

1

There is no definitive size where it becomes necessary or ideal to use an external stylesheet. Size is one factor but there are others which come into play. For example, an external stylesheet can be cached by the browser. So if your visitors will be making multiple page requests that use the same stylesheet, the browser can cache that stylesheet which will give the user faster page loads and a better experience. It also saves your server load and bandwidth.

Conversely, if this is a one page website then having the browser have to make multiple requests for assets can slow down the page load and harm the user experience (although it would be minimal).

So this decision depends on what you're doing and how you're doing it.

1
  • Thank you for mentioning that they get cached when I link to them, totally forgot about it
    – Luca Steeb
    Jan 10, 2015 at 18:19
1

I think it's important to add to this answer that many web sites will now be served via http2. If your site is, the 'multiple requests' issue isn't the same as it was before. The browser can now request multiple documents in the same transaction, making external stylesheets that haven't already been cached even quicker than ever.

1
  • I agree, I'd say it's pretty irrelevant now.
    – Luca Steeb
    Mar 29, 2022 at 7:39

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.