• Resolved yorkslad12

    (@yorkslad12)


    Hello,

    I was looking at my site source as I’m tidying it up for PageSpeed reasons. I noticed that the plugin has a <link> tag to a stylesheet, immediately followed by inline styles. This happens on every page, whether I use the code block/your plugin or not. Is there any reason to have it included on every page?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Weston Ruter

    (@westonruter)

    Hello! Yes, this is true. Originally the stylesheets were being printed conditionally when the Code block was printed, but this caused problems: https://github.com/westonruter/syntax-highlighting-code-block/issues/286

    So in https://github.com/westonruter/syntax-highlighting-code-block/pull/785 I switched it to register styles in the standard way.

    If you’re using a Block theme, then the styles will continue to be conditionally included based on whether the Code block is on the page. For a Classic theme, however, this is not the default behavior for block styles. To opt-in, you have to add this code:

    add_filter( 'should_load_separate_core_block_assets', '__return_true' );

    When you do this, all of the blocks on your site will start to be conditionally printed, not just the ones from the Code block. The downside is that the stylesheets are printed in the footer since in a Classic theme WordPress doesn’t know which blocks will be used before hand.

    Let me know if this addresses the issue.

    Thread Starter yorkslad12

    (@yorkslad12)

    Thanks for that suggestion. I’m using a ‘Frankentheme’, a theme I’ve had for years which I made block-friendly several years ago.

    Adding that filter removes the css and as far as I can tell has brought no adverse affects. So let’s say it’s worked ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.