Removing Version Numbers from CSS and JS in WordPress

Removing Version Numbers from CSS and JS in WordPress (2025 Guide)

Removing version numbers from CSS and JS in WordPress can help improve your site’s performance, boost caching efficiency, and reduce security risks. Let’s explore what version numbers do, why they matter, and how to remove them step by step.


Understanding the Impact of Version Numbers in CSS and JS Files

Whenever WordPress enqueues scripts and styles, it appends a version number like:

https://example.com/wp-content/themes/theme-name/style.css?ver=6.4.2

These version strings help with cache busting during updates, but they can interfere with browser and proxy caching. In fact, performance tools like Google PageSpeed Insights or GTmetrix often suggest removing query strings from static resources for better caching.

  1. ✅ Benefits of Removing Version Numbers from CSS and JS in WordPress

    • 🧠 Better caching: Some CDNs and proxy servers don’t cache files with query strings.

    • 🚀 Faster page loads: Efficient caching reduces load times for repeat visitors.

    • 🔐 Improved security: Hides your WordPress version from bots that exploit known vulnerabilities.

    • 📈 Higher performance scores: Get better results on tools like GTmetrix, Pingdom, and PageSpeed Insights.


    🔧 How to Remove Version Numbers in WordPress

    It’s easy to start removing version numbers from CSS and JS in WordPress using a few lines of code in your theme’s functions.php file.

    🛠️ Step-by-Step Instructions:

    1. Log in to your WordPress dashboard.

    2. Go to Appearance → Theme File Editor (or access functions.php via FTP).

    3. Add this code at the bottom of your active theme’s functions.php:

    // Remove version from scripts and styles
    function cxc_remove_css_js_version_callback( $src ) {
         if( $src && strpos( $src, '?ver=' ) ){
              $src = remove_query_arg( 'ver', $src );
         }
         return $src;
    }
    
    add_filter( 'style_loader_src', 'cxc_remove_css_js_version_callback', 9999 );
    add_filter( 'script_loader_src', 'cxc_remove_css_js_version_callback', 9999 );
    
    // Remove version from head
    remove_action('wp_head', 'wp_generator');
    
    // Remove version from RSS feed
    add_filter('the_generator', '__return_empty_string');

    ⚠️ Important: Always use a child theme or a plugin like “Code Snippets” to avoid losing custom code during theme updates.

🔒 Why Version Numbers Can Be a Security Risk

Displaying your WordPress version (via ?ver= query or meta generator tag) can leave your site vulnerable to known exploits — especially if you’re using outdated themes, plugins, or core software.

💡 Tip:

Regularly update your WordPress version and remove version disclosure to lower your security risk.


🧩 Internal Resources (on SolveWP.in)


🌐 External Reference Link


✅ Final Thoughts

Removing version numbers from CSS and JS in WordPress is a simple yet powerful way to improve site performance and security. Not only will your assets cache better, but you’ll also pass more checks in speed and audit tools.

This one tweak, when combined with caching and CDN setup, can contribute meaningfully to faster load times and a smoother user experience.

💡 Want more ways to optimize your WordPress site? Keep exploring tutorials at SolveWP.in

Do You Want To Boost Your Business?

drop us a line and keep in touch