• Hi,
    I’ve the following problem. My WP site sometimes don’t load correclty the CSS, infact in Apache log, when the problem occurs, two lines don’t appears:

    [14/Jun/2016:15:18:27 +0200] "GET /wp-includes/css/dashicons.min.css,qver=4.4.pagespeed.ce.X2cvQ4DGDW.css HTTP/1.1" 304 -
    [14/Jun/2016:15:18:27 +0200] "GET /wp-includes/css/admin-bar.min.css,qver=4.4.pagespeed.ce.IzXC0ivIXx.css HTTP/1.1" 304 -
    [14/Jun/2016:15:18:27 +0200] "GET /wp-content/themes/mineral/css/A.prettyPhoto.css,qver=1.5.4.pagespeed.cf.hwHBzDR-Sf.css HTTP/1.1" 304 -

    Normally, when it works correctly, the log shows:

    [14/Jun/2016:15:21:06 +0200] "GET /wp-includes/css/dashicons.min.css,qver=4.4.pagespeed.ce.X2cvQ4DGDW.css HTTP/1.1" 304 -
    [14/Jun/2016:15:21:06 +0200] "GET /wp-includes/css/admin-bar.min.css,qver=4.4.pagespeed.ce.IzXC0ivIXx.css HTTP/1.1" 304 -
    [14/Jun/2016:15:21:06 +0200] "GET /wp-content/themes/mineral/css/A.prettyPhoto.css,qver=1.5.4.pagespeed.cf.hwHBzDR-Sf.css HTTP/1.1" 304 -
    [14/Jun/2016:15:21:06 +0200] "GET /wp-content/themes/mineral_child/style.css?ver=1.5.4 HTTP/1.1" 200 215
    [14/Jun/2016:15:21:06 +0200] "GET /wp-content/themes/mineral/style.css HTTP/1.1" 200 21432

    How can I understand where is the problem?

    Thanks.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Without seeing the code first hand it appears to me that your child theme is not calling the CSS style sheets correctly.

    Thread Starter David @roundrobined

    (@dvdscr)

    Hi,
    thanks for your reply.
    I don’t think it is a problem of the child theme, but I can try to disable it, because in the first case (when the error occurs) there are not GETs about the style.css files. I mean that it not fails, simply the GET don’t appear.
    I don’t understand why in this case I can see in the log the style.css files.

    I was not suggesting you disable the child theme. I was suggesting that there are import statements like this one missing from the child themes css.

    @import url("../themify-ultra/style.css");

    You need be sure that you have all the import statements in your child themes CSS. If any are missing that is why it does not load consistently.

    Doing an @import is no longer a good practice according to the codex.

    Please see this guide.

    Quoted from the codex:

    The final step is to enqueue the parent and child theme stylesheets. Note that the previous method was to import the parent theme stylesheet using @import: this is no longer best practice, as it increases the amount of time it takes style sheets to load. The correct method of enqueuing the parent theme stylesheet is to add a wp_enqueue_scripts action and use wp_enqueue_style() in your child theme’s functions.php

    @supporthero, when was this change made? I have been working with WP for ten years and as recently as December 2015 I had checked and @import was still mentioned in the codex so I have been sticking with that.

    @dvdscr, My point still stands, maybe you have not enqueued all styles and scripts in the child theme and that is why it is not loading correctly or loads correctly on an inconsistent basis.

    I think it was updated in 2014. The codex reference that I linked has additional references in the bottom. Here’s the reference as to why @import is not a good idea.

    Anyway, I’m not here to argue. I just want to share what I know based from the WordPress bible which is the codex. If you want to enqueue styles and scripts, the codex recommends that you do it in functions.php.

    @supporthero, I am not here to argue either. I was simply asking a question! Maybe I had the page cached locally or something weird like that. Whatever, thank you for bringing this to my intention.

    Thread Starter David @roundrobined

    (@dvdscr)

    @binarywc, @supporthero, thanks for your answers.
    The problem probably is @import. In fact if I disable child theme or if I disable pagespeed apache module with child theme enabled, it works correctly.
    Probably pagespeed module sometimes not allows to charge the imported CSS in time.
    Now I can try to remove @import and to renable pagespeed module.

    I test it and I tell you.
    David

    We are always glad to help! Thats what the support community is here for!

    Thread Starter David @roundrobined

    (@dvdscr)

    Hi,
    I’ve finally solved. Disabling “pagespeed” module, it works. Anyway, I enable it again, because the problem is between the “speed” and the @import code in CSS file.

    Thanks a lot,
    David

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Sometimes CSS not loading’ is closed to new replies.