Buy All 47 Premium Themes For the Price Of $199.99

How to Disable Unused WordPress Scripts and Speed Up Your Website

One of the most overlooked performance problems in WordPress is loading scripts and styles on pages where they are not needed.
For example, WooCommerce loads assets on every page by default, even if it is not a shop page.

In this article, you will learn how to properly disable unused scripts using WordPress hooks to dramatically improve site speed and Core Web Vitals.

Why This Matters for Performance

Every extra CSS or JavaScript file increases loading time and affects user experience.

  • Slower page load speed
  • Lower Google PageSpeed score
  • Worse mobile performance
  • Higher bounce rate

Common Problem in WordPress

Many plugins load assets globally even when they are not needed.
WooCommerce, contact forms, sliders, and page builders often add unnecessary scripts site-wide.

Solution: Use wp_dequeue_script and wp_dequeue_style

WordPress provides hooks that allow you to remove scripts and styles conditionally.


add_action('wp_enqueue_scripts', 'disable_unused_assets', 100);

function disable_unused_assets() {

    // Disable WooCommerce scripts on non-shop pages
    if (!is_woocommerce() && !is_cart() && !is_checkout()) {

        wp_dequeue_script('wc-cart-fragments');
        wp_dequeue_script('woocommerce');
        wp_dequeue_style('woocommerce-general');
        wp_dequeue_style('woocommerce-layout');
    }

    // Disable Contact Form 7 scripts if not on contact page
    if (!is_page('contact')) {

        wp_dequeue_script('contact-form-7');
        wp_dequeue_style('contact-form-7');
    }
}

How It Works

  • Checks current page type using conditional tags
  • Removes unnecessary scripts and styles
  • Reduces HTTP requests and page weight

Advanced Optimization Tips

  • Use asset loading only on specific pages
  • Disable emoji scripts in WordPress
  • Remove jQuery Migrate if not needed
  • Combine with caching and CDN

Disable WordPress Emojis (Bonus)


remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');