Aleš Sýkora wrote

Dequeue WooCommerce JS and CSS

If you do not use default WooCommerce Photoswipe lightbox, flexslider and other libraries, you can dequeue them for faster loading of your site.

I am doing that especially when I use the Oxygen Builder because in most times I build my own product galleries with fancybox.

How to do Dequeue WooCommerce JavaScripts and CSS styles?

Create your new PHP script in your scripts organizer, code snippets plugin, advanced scripts etc. and put the code below in new snippet.

You can add the styles and scripts as you need. Here is a list of styles and scripts I have found yet:

‘photoswipe’ ,
Do you know more WooCommerce JS and CSS to dequeue? Let me know in comments section below. Thanks!

The code below disable loading of photoswipe CSS and JS, Woocommerce block styles, flexslider JS and Zoom js.

add_action( 'wp_enqueue_scripts', 'twiki_dequeue_woocommerce_styles', 99 );
function twiki_dequeue_woocommerce_styles() {

// styles
        $dequeue_styles = array(
        foreach ( $dequeue_styles as $dstyles ) :
            wp_dequeue_style( $dstyles );

// scripts

$dequeue_scripts = array(
            'photoswipe' ,
        foreach ( $dequeue_scripts as $dscripts ) :
            wp_dequeue_script( $dscripts );

You can also use the official WooCommerce documentation to disable the WooCommerce stylesheets by recommended way to build own theme:

add_filter( 'woocommerce_enqueue_styles', '__return_empty_array' );

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

More from category
Aleš Sýkora wrote
Auto-populate child content with parent content’s title
11. 7. 2019 in
Code snippet from our fan.
Read More
Aleš Sýkora wrote
Oxygen Lazy Load Gallery (Working 2021)
8. 4. 2020 in ,
Tutorial for working Lazy Load solution for Oxygen Builder gallery module.
Read More
Aleš Sýkora wrote
Oxygen Pro Menu Entire Parent Toggle Dropdown not working
22. 3. 2021 in ,
If you want to have your dropdowns shown in mobile menu with toggle, you are propably using Oxygen’s Pro menu option “Entire Parent Toggles Dropdown”. And it works fine, in most cases. But there is an issue with custom links. If your link uses # then this option doesn’t work. You need to use /# […]
Read More
magnifiercross linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram