

Here’s what that type of file might look like.
WP ENQUEUE STYLE WOOCOMMERCE CODE
You can include this code directly in the functions.php file of your theme, but I generally load a separate file as a class either from a mu-plugin or the theme. I’ve limited the dequeues to the front page of the site in these code blocks, but you can use different page conditionals to remove the scripts and styles from where they are not needed. Wp_dequeue_style( 'woocommerce-inline' ) Īdd_action( 'wp_enqueue_scripts', 'prefix_remove_styles', 100 ) Wp_dequeue_style( 'wc-block-vendors-style' ) * Remove styles that have been enqueued by other plugins. To dequeue styles you can use the wp_enqueue_scripts hook: /** Wp_dequeue_script( 'storefront-header-cart' ) Īdd_action( 'wp_print_scripts', 'prefix_remove_scripts', 100 ) Wp_dequeue_script( 'wc-cart-fragments' ) * Remove scripts that have been enqueued by other plugins.

To dequeue scripts you can use the wp_print_scripts hook. It will also show you the “handle”, which is needed to dequeue the asset. Query monitor will show you all the scripts enqueued by WordPress for a specific page. Screenshot of site with Query Monitor running

This will let you know which scripts and styles are enqueued for a specific page. To find our which scripts and styles are enqueued, you’ll need to do a some detective work. I recently went on a performance rampage at Universal Yums and removed ~300kb of enqueued assets that were not needed on our home page- which shows there can be quite a bit of fat to trim. For example, WooCommerce loads at least 3 scripts and 4 styles on every page, even if ecommerce functionality (like a cart or products) aren’t shown on those pages. Many WordPress plugins load scripts and styles on every page of a website even though they may just be needed on a few specific pages.
