• I’ve noticed a spike in people whose child themes are not inheriting the parent theme’s styles because they have commented out the @import url( '../parent-theme/style.css' ); line in their child theme’s stylesheet. I was surprised to discover that the Codex page on child themes has that line commented out as well, and while it is possible to use wp_enqueue_style() in your child theme’s functions.php to load your parent theme’s stylesheet, the Codex does not mention that at all.

    So two questions here:

    1) Why does the Codex page currently have the @import line commented out in the sample child theme stylesheet?
    2) I’d like to fix this, but if the decision to comment out that line was due to a discussion made elsewhere, I don’t want to step on anyone’s toes. Should the Codex recommend the use of @import by default, and if so, should the Codex mention the use of wp_enqueue_style as well?

Viewing 1 replies (of 1 total)
  • .

    (@techievous)

    I don’t know about internal discussions, but it has been the standard for a few years now to use enqueue instead of @import. It allows much more flexibility to everyone–including theme developer and plugin developers.

    Also, @import affects performance, negatively: https://developers.google.com/speed/docs/best-practices/rtt#AvoidCssImport

    The recommendation to use enqueue instead of @import has been going around since 2009; it’s a good thing that it’s finally caught on (5 years later, heh). I personally would not recommend @import as the main method again and destroy all that progress.

Viewing 1 replies (of 1 total)
  • The topic ‘Codex: @import vs wp_enqueue_style in child themes’ is closed to new replies.