Skip Navigation

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

Problem:
The client wants to dequeue WPML stylesheets from the code for optimization purposes.

Solution:
To disable the “wpml-legacy-horizontal-list-0-css” and “wpml-menu-item-0-css” files, please add the below code in your theme functions.php file:

define('ICL_DONT_LOAD_LANGUAGE_SELECTOR_CSS', true);

Relevant Documentation:
https://wpml.org/documentation/support/wpml-coding-api/#disabling-wpmls-css-and-js-files

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.

This topic contains 2 replies, has 2 voices.

Last updated by kasperv-6 1 year, 10 months ago.

Assisted by: Noman.

Author Posts
March 3, 2023 at 1:54 am #13159477

kasperv-6

Tell us what you are trying to do?
I am trying to dequeue stylesheets from the code for optimisation purposes.

Is there any documentation that you are following?
I have checked the following support docs:
https://wpml.org/documentation/support/wpml-coding-api/#disabling-wpmls-css-and-js-files
https://wpml.org/documentation/support/wpml-coding-api/wpml-constants/
https://wpml.org/forums/topic/wpml-loads-a-css-file-and-a-js-file-on-every-page-is-this-necessary/page/2/

What is the link to your site?
hidden link

I am trying to dequeue the following styles:
wp_dequeue_style('wpml-legacy-horizontal-list-0-css');
wp_dequeue_style('wpml-menu-item-0-css');

I have used the following code inside my functions.php:

function wt_disable_wpml_styles() {

wp_dequeue_style('wpml-legacy-horizontal-list-0-css');
wp_dequeue_style('wpml-menu-item-0-css');

}
add_action( 'wp_enqueue_scripts', 'wt_disable_wpml_styles', 10000 );

Also I defined the constants:
define('ICL_DONT_LOAD_NAVIGATION_CSS', true);
define('ICL_DONT_LOAD_LANGUAGE_SELECTOR', true);
define('ICL_DONT_LOAD_LANGUAGES_JS', true);

But nothing seems to work. What am I doing wrong here?

Regards, Kasper

March 5, 2023 at 4:38 pm #13173895

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting WPML Support. To disable the “wpml-legacy-horizontal-list-0-css” and “wpml-menu-item-0-css” files, please add the below code in your theme functions.php file:

define('ICL_DONT_LOAD_LANGUAGE_SELECTOR_CSS', true);

I have just tested at the fresh WP site here:
view-source:hidden link and it seems to be working correctly for me.

Here is a doc for more details:
https://wpml.org/documentation/support/wpml-coding-api/#disabling-wpmls-css-and-js-files

If still the issue persists, please take a complete backup of your site and update WPML plugins to the latest 4.6 version and see if this resolves your issue.

Thank you