File tree 1 file changed +30
-0
lines changed
1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change
1
+ func/*
2
+ * add this function in your theme function.php file or in your child theme function.php
3
+ * this will stop woocommerce css and js file to load on non woocommerce page if woocommerce is active
4
+ */
5
+ add_action( 'wp_enqueue_scripts', 'stop_woocommerce_loading_css_js' );
6
+
7
+ function stop_woocommerce_loading_css_js() {
8
+
9
+ // Check if WooCommerce plugin is active
10
+ if( function_exists( 'is_woocommerce' ) ){
11
+
12
+ // Check cuurent page is WooCommerce page or not
13
+ if(! is_woocommerce() && ! is_cart() && ! is_checkout() ) {
14
+
15
+ ## Dequeue WooCommerce styles
16
+ wp_dequeue_style('woocommerce-layout');
17
+ wp_dequeue_style('woocommerce-general');
18
+ wp_dequeue_style('woocommerce-smallscreen');
19
+
20
+ ## Dequeue WooCommerce scripts
21
+ wp_dequeue_script('wc-cart-fragments');
22
+ wp_dequeue_script('woocommerce');
23
+ wp_dequeue_script('wc-add-to-cart');
24
+
25
+ wp_deregister_script( 'js-cookie' );
26
+ wp_dequeue_script( 'js-cookie' );
27
+
28
+ }
29
+ }
30
+ }
You can’t perform that action at this time.
0 commit comments