Title: Block css
Last modified: January 30, 2025

---

# Block css

 *  Resolved [deargeek](https://wordpress.org/support/users/deargeek/)
 * (@deargeek)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/block-css-2/)
 * Is there a way (or could there be) to disable loading login-block-style.css when
   the block isn’t being used?
 * I’m a PageSpeed Insights score junkie!

Viewing 1 replies (of 1 total)

 *  Plugin Author [Mustafa Uysal](https://wordpress.org/support/users/m_uysl/)
 * (@m_uysl)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/block-css-2/#post-18275581)
 * Hi [@deargeek](https://wordpress.org/support/users/deargeek/),
 * > Is there a way (or could there be) to disable loading login-block-style.css
   > when the block isn’t being used?
 * It’s already working that way! (I just tested with the default theme, and login-
   block-style.css is not loaded when the Magic Login block isn’t present on the
   page.)
 * However, if you are using a classic theme WP enqueues block style globally (AFAIK).
   You can try something like this:
 *     ```
       function magic_login_maybe_dequeue_block_style() {
       	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' );
       	}
       }
       add_action( 'wp_enqueue_scripts', 'magic_login_maybe_dequeue_block_style', 20 );
       ```
   
 * I hope this helps!

Viewing 1 replies (of 1 total)

The topic ‘Block css’ is closed to new replies.

 * ![](https://ps.w.org/magic-login/assets/icon.svg?rev=2783285)
 * [Magic Login - Passwordless Authentication for WordPress - Login Without Password](https://wordpress.org/plugins/magic-login/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/magic-login/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/magic-login/)
 * [Active Topics](https://wordpress.org/support/plugin/magic-login/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/magic-login/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/magic-login/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Mustafa Uysal](https://wordpress.org/support/users/m_uysl/)
 * Last activity: [1 year, 4 months ago](https://wordpress.org/support/topic/block-css-2/#post-18275581)
 * Status: resolved