Support » Plugin: Blocks CSS: CSS Editor for Gutenberg Blocks » Inject CSS in wp footer

  • Resolved Elly Post


    Is there a hook we can connect to to insert the CSS in the body of the document instead of the head? ideally we’d like to trigger it when we call wp_footer() such that it is not render blocking since our use case is not for above-the-fold items.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Elly Post


    Update: it looks like this currently is being injected through the following code:

    add_action( 'wp_head', array( $this, 'render_server_side_css' ) );

    This is from wp-content/plugins/blocks-css/vendor/codeinwp/gutenberg-css/class-gutenberg-css.php

    May I suggest a PR for something like:

    $css_hook = apply_filters('themeisle_gutenberg_css', 'wp_head');
    add_action( $css_hook, array( $this, 'render_server_side_css' ) );

    With this then the theme author could do something like

    add_filter('themeisle_gutenberg_css', function($hook){
       return 'wp_footer';
    • This reply was modified 1 year, 8 months ago by Elly Post. Reason: Fix markup
    Plugin Author Hardeep Asrani


    Hey @ellytronic,

    Sure, feel free to send a PR our way and we shall merge it:

    You can have the filter name being themeisle_gutenberg_css_render_location

    Let me know your thoughts. 🙂

    Plugin Author Hardeep Asrani


    If you do, make sure to send the PR to development branch of the repository. 🙂

    Thread Starter Elly Post


    Hey @hardeepasrani,

    Thinking on this further and with a little more review of the code, it can be solved simply like this:

    $gutenberg_css = \ThemeIsle\GutenbergCSS::instance();
    remove_action('wp_head', [$gutenberg_css, 'render_server_side_css']);
    add_action('wp_footer', [$gutenberg_css, 'render_server_side_css']);

    It doesn’t look like the repo you shared has the readme since it’s a composition plugin, but feel free to add that to your README file! 🙂

    Plugin Author Hardeep Asrani


    Yea, we use a composer package to make these features and then bundle them in the plugins. 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Inject CSS in wp footer’ is closed to new replies.