How to unload select2 script/styles loaded by new WooCommerce 2.3.x?


Staff member
we are theme developers and we already use select2 (<a href="" rel="noreferrer"></a>) script for SELECT boxes in HTML in our wordpress theme.
New WooCommerce 2.3.x that just relased now use select2 scripts too. But they override its styles with its own (most of all with !important tags) in many different ways.

We can't redeclare all of their CSS changes with !important rules, this will be a lot of CSS mess that we don't like. Also now our JS script loaded 2 times and conflicts sometimes too (because woocommerce loads its own select2 js).

My question is what is a best way to deactivate woocommerce select2 CSS and JS files in our theme functions? We want to use our script version and our styles file (for woocommerce select elements too).

I tryed to use wp_dequeue_script, wp_deregister_script and the same functions available for styles, but this does not help. As I see woocommerce add scripts/css AFTER our theme already initialized and we can't deactivate it.


This is code that loaded in /includes/class-wc-frontend-scripts.php that I need to disable from theme functions:

self::register_script( 'select2', $assets_path . 'js/select2/select2' . $suffix . '.js', array( 'jquery' ), '3.5.2' );
self::enqueue_script( 'select2' );
wp_enqueue_style( 'select2', $assets_path . 'css/select2.css' );

How to unload this CSS/JS files in theme functions, without changing original WooCommerce files?