Search code examples
csscode-generationinternal

Does a long internal stylesheet affect SEO?


I'm building a site with a lot of similar css between pages. I've decided that a good approach would be to have the css generated as strings by php functions (with parameters) and outputed as an internal stylesheet in every page that i serve. The benefits:

  • this way if i make a change it will reflect throughout the entire site without having to maintain duplicates
  • i can send only the necessary css for a certain page
  • it's better than having small css files and sending a lot of css headers at inclusion
  • the possibility that the content might be displayed before the stylesheet is loaded is gone
  • i can calculate dimensions by using parameters
  • i can create a layer that will minify the result received from these functions or serve cached minified css

I haven't seen this done anywhere else unfortunately so i'm thinking that this might be because of SEO. The generated internal stylesheet will be at around 15kb max (before minifying the stylesheet).

I need your opinion on this approach and your thoughts about the impact a long internal stylesheet will have on SEO.

Many thanks.


Solution

  • Not an answer to your question (which is interesting enough!), but most of your arguments for inline CSS are wrong. An external style sheet is always the better and faster solution.

    • The first point you can handle by adding a version number to the style sheet's file name

    • The second point is moot because an external file gets cached, so no additional requests

    • The third point is moot for the same reason

    • The fourth point won't really matter once the style sheet is cached

    • The fifth point can be sorted using inline CSS for only the properties that need to be updated dynamically - usually a tiny fraction of the whole CSS code base

    • The sixth point I don't get.

    Go for an external style sheet. Just make sure it gets served with the correct caching headers!