PluginUs.Net - Business Tools for WooCommerce and WordPress

[realize your idea - make your dreams come true]
Botoscope is currently in early access

Support Forum

You need to log-in to create request (topic) to the support

Remove useless CSS and JS

The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday. If you have problems with registration ask help on contact us page please
If you not got email within 24~36 business hours, firstly check your spam box, and if no any email from the support there - back to the forum and read answer here. DO NOT ANSWER ON EMAILS [noreply@pluginus.net] FROM THE FORUM!! Emails are just for your info, all answers should be published only here.
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday.

Hello

I used the wSelect drop-down template to create a currency switcher on the product page. Other than that, I don't use any other features. I noticed that your plugin loads 6 JS and CSS files, most of which are unnecessary, like front.css and price-slider_33.js. I edit the PHP files to remove them, and it won't affect the plugin's functionality; they only slow down the loading speed.

How can I delete front.css and price-slider_33.js without editing PHP files, because that would affect plugin updates?

Also, what are the functions of real-active-filters.js and real-price-filter-frontend.js?

/woocommerce-currency-switcher/js/wselect/wSelect.css
/woocommerce-currency-switcher/css/front.css
/woocommerce-currency-switcher/js/price-slider_33.js
/woocommerce-currency-switcher/js/real-active-filters.js
/woocommerce-currency-switcher/js/real-price-filter-frontend.js
/woocommerce-currency-switcher/js/wselect/wSelect.min.js

Hello

Here is what each of those files actually does:

front.css contains styling only for the other dropdown view types (ddslick, chosen, flags view, and the converter shortcode). It has nothing related to the wSelect dropdown at all, so since you only use wSelect, this file is indeed not needed in your case.

price-slider_33.js overrides the slider used by the classic WooCommerce Filter by Price widget, so the price range gets converted into the selected currency.

real-active-filters.js overrides the WooCommerce Blocks Active Filters block, again to show the converted currency in the active filter labels.

real-price-filter-frontend.js does the same thing but for the block version of the Filter by Price block (the Gutenberg block, not the classic widget).

If you are not using the price filter (neither the classic widget nor the block) and not using the Active Filters block, then yes, those three JS files are not needed for your setup either.

To remove them cleanly without editing any plugin files, the safest method is to filter the actual tag output by handle, in your theme's functions.php or a small custom plugin. This works regardless of how or when the plugin enqueues them, so it will keep working through plugin updates:

add_filter('script_loader_tag', function ($tag, $handle) {
	if (in_array($handle, array(
			'wc-price-slider_33',
			'woocs-real-active-filters',
			'woocs-price-filter-frontend',
			), true)) {
		return '';
	}
	return $tag;
}, 10, 2);

add_filter('style_loader_tag', function ($tag, $handle) {
	if ($handle === 'woocommerce-currency-switcher') { // front.css
		return '';
	}
	return $tag;
}, 10, 2);

 

Please do not remove wSelect.css or wSelect.min.js (handle woocs_wselect), those are exactly what powers your dropdown, removing them would break it.

 

Thank you very much, your code works fine. I noticed there's also a /woocommerce-currency-switcher/js/front.js. Is it necessary or can it be removed? If it can be removed, please provide the removal code along with the previous JS files.

Hello

front.js is the core script of the currency switcher itself. It handles the actual currency switching logic, price updates on the page, and session/cookie handling. Unlike front.css, which only contains styling for the other dropdown view types, front.js is required for the currency switcher to function at all, regardless of which dropdown type you use, including wSelect.

So this file should not be removed, otherwise the currency switching functionality will stop working entirely.

Welcome!