Home > OS >  Is external css file really more performant than style tag?
Is external css file really more performant than style tag?

Time:10-06

I heard that external css file can be cached by the browser so it improve performance of the web.

My question is that is it real?

Will cached css file really improve the performance?

CodePudding user response:

No, it doesn't change anything even for loading time!

As all files are cached by default (even the HTML), loading time doesn't change.

And the browser doesn't care about where you put your style.

Traditionally, using the style tag or style attribute is not recommended but it is related to the readability of the code only. This does not change anything for the user.

CodePudding user response:

Indeed, browsers will try to cache CSS style sheets (within limitation) so that it's only fetched once, and served on demand. This saves network bandwidth.

It can be assumed that CSS will not change much compared to the content of the website. Therefore, depending on the implementation, splitting the style definitions away from the content, especially if designed for reusability is often the ideal approach.

  • Related