Stylesheet loaded in footer

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #4452
    jhodgski
    Member

    Is there any particular reason why the plugins.css stylesheet is loaded in the footer?

    It gives a W3C validation error, and isn’t it better practice to load all the stylesheets in the header?

    To overcome this, I’ve added this code to my functions.php file…

    
    /*
     * Load plugins.css in header not footer
     */
    remove_action('wp_footer', 'mo_enqueue_plugin_styles');
    add_action('wp_enqueue_scripts', array(&$this, 'mo_enqueue_plugin_styles'), 100);

    …everything still seem to render and work fine. Just wanted to check whether or not you knew of any issue with me doing this?

    #4477
    Raghavendra
    Moderator

    You have done the right thing – giving the priority 100 and works for most part. Have changed the code on my part as this –

            add_action('wp_head', array(&$this, 'mo_enqueue_plugin_styles'), 12); 
    

    and this change will be in the next update. Pls note that wp_head action fires at priority 10 while wp_enqueue_scripts fires at priority 0 by default. I found wp_head to be a safer bet and helps place the stylesheet just above the head end tag. Will ensure our css loads last and is able to override the plugin styles.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Agile Theme Support’ is closed to new topics and replies.