WordPress.org

Ready to get started?Download WordPress

Forums

Combine multiple css stylesheets (6 posts)

  1. Maleficus
    Member
    Posted 4 years ago #

    I'm using a suffusion theme, which utilizes around 10 stylesheets and I've heard it's better to combine them into one. So I'm asking what options do I have to combine them safely and without any bugs so that things will keep working in future as if nothing happened. Do I just paste all other css's to the end of style.css?

  2. Peter Boosten
    Member
    Posted 4 years ago #

    I cannot think of any reason why it would be better to have one stylesheet instead of several.

    Maybe someone can shed some light on this?

    Anyhow: the styles closest to your xhtml are leading in case of a conflict, so when you decide to put everything in one stylesheet, make sure it has the same order as it is in your current <head></head>.

    Peter

  3. Maleficus
    Member
    Posted 4 years ago #

    As far as I know having multiple css files requires more HTTP requests, thus taking the page longer to load.

  4. Mark / t31os
    Moderator
    Posted 4 years ago #

    If you're loading all those stylesheets on every page, then yes it's better in 1 file..

    It really depends if any of those stylesheets only load under certain conditions or whether they're loaded on EVERY page.

    Alternatively you could look at placing conditions round the stylesheet calls.

    Let's say for example you have some custom comments CSS, that's only used when you're viewing a single entry (single.php / comments.php) ... it would make no sense to have those styles loaded for every page, when you could load them as and when they're needed..

    ie.

    <?php if(is_single || is_singular) { // include styles/stylesheet stuff here } ?>

    That way your custom comments styles (per example) would only be loaded as and when they are needed.

  5. Peter Boosten
    Member
    Posted 4 years ago #

    If you're loading all those stylesheets on every page, then yes it's better in 1 file..

    I wonder... wouldn't those stylesheets not be cached on your local drive? Furthermore, in a corporate environment, it's more likely that small files get cached in a proxy server, while larger files wouldn't (squid for instance has a default maximum cache size of 4Kb).

    You might want to consider the overhead of setting up tcp sessions for every request your browser has to do to the web server, however since http/1.1 persistent connections are default, saving the session setup overhead.

    OTOH: having one stylesheet keeps administration of it a bit easier, since you don't have to search for the right file to make changes.

    I would go for one file (unless the stylesheet is used for different purposes - screen vs print) :-)

    Peter

  6. Catherine
    Member
    Posted 3 years ago #

    This plugin seems to do the trick:
    halmatferello.com/lab/wp-css/

Topic Closed

This topic has been closed to new replies.

About this Topic