• I am planning to relaunch my site using generatepress, see attached url.

    Pagespeed Insights looks promising, but tells me to reduce critical path css.

    Is there anything I can do to optimize this further?

    Thanks a lot!

    • This topic was modified 2 years, 2 months ago by anzgar.

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Leo

    (@leohsiang)

    Thread Starter anzgar

    (@anzgar)

    So you are basically telling me to install autoptimize.

    I ask myself wether dequeueing unneeded css on certain pages might be even more efficient than installing another plugin.

    Any thoughts on this? Thanks!

    Hi there,

    there are some core style sheets you can remove if you’re not using core blocks in your build that can be dequeued with this snippet:

    // remove block library styles
    function db_dequeue_block_styles(){
        wp_dequeue_style( 'wp-block-library' );
        wp_dequeue_style( 'wp-block-library-theme' );
    } 
    add_action( 'wp_enqueue_scripts', 'db_dequeue_block_styles', 100 );

    There is also the core global styles, including the huge list of color variables, utility classes and the related SVG HTML that it adds for those Duo-tone color options on its blocks

    // remove core global styles and SVG filter HTML
    function db_remove_global_css_and_svg() {
    	remove_action( 'wp_enqueue_scripts', 'wp_enqueue_global_styles' );
    	remove_action( 'wp_body_open', 'wp_global_styles_render_svg_filters' );
    }
    add_action('init', 'db_remove_global_css_and_svg');

    Of course you need to be sure that you don’t require those styles. Neither GP or GB rely on them. But please check carefully if you choose to remove.

    You may want to consider disabling emojis as well, as that makes a javascript request. Read more here:

    https://www.netmagik.com/how-to-disable-emojis-in-wordpress/

    For GeneratePress specific improvements, there is an option in the Customizer > General where you can set the Dynamic CSS Print Method to an External File and set the Cache dynamic CSS

    Hope that helps

    • This reply was modified 2 years, 1 month ago by David.
    Thread Starter anzgar

    (@anzgar)

    Hi David,

    thanks that really helps.

    So you are saying dequeuing files does make sense? Would you install autoptimize at all?

    Thanks a lot!

    Thread Starter anzgar

    (@anzgar)

    One more thing:

    Which blocks are considered core blocks? Is there a list somewhere?

    Core blocks are every block that isn’t listed under a plugin name. For example if you Add Block and Browse All blocks you will see that the GenerateBlocks are listed under their own heading. Anything without a plugin named heading is core ??

    Dequeuing unnecessary scripts / styles is sensible. You just need to make sure your site is not dependent on them. The simplest way to tell is to add the snippets, and check the site for breakages.

    Autoptimize, hmmm….. it is a good plugin and can help reduce load times, test it, if it makes an improvement then use it ??

    As your site is already returning high 90s scores anyway, there isn’t a lot to improve. I would probably look at enabling page caching on the server ( if available ) as a final optimization.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Reduce amount of css files’ is closed to new replies.