0

In WordPress version 6.3, create a transient named "_transient_wp_core_block_css_files" (~0.4MB) in the wp_options table to store the list of CSS files to load when using WordPress' blocks. When the site loads and needs to use the block, WordPress checks this transient to determine if the CSS files need to be loaded.

I don't use the block. I tried to set autoload from "yes" to "no" but failed:

  1. I try to change yes to no in phpmyadmin but no success.
  2. I try this in funtions.php but no success. add_filter( 'block_styles_should_load', '__return_false' ); delete_transient( '_transient_wp_core_block_css_files' );

Do you know any better way?

1
  • actually you do, there is no wp_core_block it's for all core blocks, be that headings, paragraphs, etc etc, by changing this to autoload false you'll be reducing performance by making it do a second small DB query to fetch its value. I know you're hoping to reduce weight and make things faster/cleaner but you're actually doing the opposite unintentionally!
    – Tom J Nowell
    Commented Aug 9, 2023 at 12:26

2 Answers 2

2

Don't bother messing the with autoload on the transient. If you're truly not using blocks at all, just unhook the function that creates the transient and uses it to register the style handles:

remove_action( 'init', 'register_core_block_style_handles', 9 );

Just be aware that if you do use blocks, their stylesheets will not load until you let WordPress create the transient again.

2
  • Thank Jacob Peattie!
    – Tuan vn
    Commented Aug 9, 2023 at 12:36
  • It is not working for me. _transient_wp_core_block_css_files : 46832
    – Tuan vn
    Commented Aug 9, 2023 at 12:38
0

It is work for me.

function remove_core_block_style_handles() {
    remove_action( 'init', 'register_core_block_style_handles', 9 );
}
add_action( 'init', 'remove_core_block_style_handles' );


if ( function_exists( 'delete_transient' ) ) {
    delete_transient( 'wp_core_block_css_files' );
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.