Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
You are trying to dequeue the

/sitepress-multilingual-cms/dist/css/blocks/styles.css

file because you do not use the blocks editor on your website and wish to optimize your site by removing it. However, you encountered a warning about the missing

wpml-blocks

style.

Solution:
We recommend adding the following code to your theme's functions.php file to dequeue the

wpml-blocks

style:

add_action('wp_enqueue_scripts', 'test_remove_style', 11, 2);
function test_remove_style() {
  wp_dequeue_style('wpml-blocks');
}

If this solution does not seem relevant to your issue, please open a new support ticket with us.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Tagged: 

This topic contains 3 replies, has 2 voices.

Last updated by Christopher Amirian 1 year, 6 months ago.

Assisted by: Christopher Amirian.

Author Posts
November 10, 2023 at 2:15 pm #14777537

alexG-60

I am trying to: deque /sitepress-multilingual-cms/dist/css/blocks/styles.css

Since I don't use the blocks editor on my website I don't need /sitepress-multilingual-cms/dist/css/blocks/styles.css. In optimization porposes, I want to deque it, but can't find the right solution of doing this. Could you please help me?

I expected to see: No warnings

Instead, I got: warning that wpml-blocks missing (1 screenshot). Is it ok?

// Remove WPML blocks srtyle css
function prefix_disable_wpml_block_styles() {
if ( class_exists( 'WPML\BlockEditor\Loader' )) {
wp_deregister_style( WPML\BlockEditor\Loader::SCRIPT_NAME );
}
}

add_action( 'wp_enqueue_scripts', 'prefix_disable_wpml_block_styles', 11 );

Thank you!

01.png
November 12, 2023 at 4:42 pm #14784393

Christopher Amirian
WPML Supporter since 07/2020

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi there,

Please use the constant below to remove CSS loading from WPML:

https://wpml.org/documentation/support/wpml-coding-api/wpml-constants/#icl_dont_load_language_selector_css

You can add it to a PHP file of your theme:

define( 'ICL_DONT_LOAD_LANGUAGE_SELECTOR_CSS', true );

Thanks.

November 12, 2023 at 5:47 pm #14784629

alexG-60

Hi,

Ok, but this constant doesn't remove: /plugins/sitepress-multilingual-cms/dist/css/blocks/styles.css

This constant removes only: /plugins/sitepress-multilingual-cms/templates/language-switchers/menu-item/style.min.css

How can I remove this: /plugins/sitepress-multilingual-cms/dist/css/blocks/styles.css?

Thank you.

November 13, 2023 at 9:17 am #14786561

Christopher Amirian
WPML Supporter since 07/2020

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi there,

Thank you. Would you please add the code below on your theme and see if it works?

add_action ('wp_enqueue_scripts', 'test_remove_style', 11, 2);
function test_remove_style() {
wp_dequeue_style('wpml-blocks');
}

Thanks.

November 14, 2023 at 12:08 pm #14797333

alexG-60

Wow, that simple, thanks! It worked