You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, in classic (non-block) themes, block-specific CSS is loaded globally, even when the block is not present on the page. This behavior is different from how block themes handle styles, where styles are only loaded when the block is used.
For better performance and to avoid unnecessary asset loading, we should ensure that block CSS is only enqueued when the block is actually present on the page.
Current workaround:
function magic_login_maybe_dequeue_block_style() {
// Only run this check on the frontend, not in the admin panel.
if ( is_admin() ) {
return;
}
// Get the current post content
global $post;
// If the post content doesn't contain the block, dequeue the CSS.
if ( $post && ! has_block( 'magic-login/login-block', $post ) ) {
wp_dequeue_style( 'magic-login-login-block' );
wp_deregister_style( 'magic-login-login-block' );
}
}
add_action( 'wp_enqueue_scripts', 'magic_login_maybe_dequeue_block_style', 20 );
The text was updated successfully, but these errors were encountered:
Currently, in classic (non-block) themes, block-specific CSS is loaded globally, even when the block is not present on the page. This behavior is different from how block themes handle styles, where styles are only loaded when the block is used.
For better performance and to avoid unnecessary asset loading, we should ensure that block CSS is only enqueued when the block is actually present on the page.
Current workaround:
The text was updated successfully, but these errors were encountered: