How to Remove Query Strings From Static Resources in WordPress

How to Remove Query Strings From Static Resources in WordPress

Spread The Love

Remove Query Strings From Static Resources

When we talk about WordPress Performance, The question of query string arises like How to Remove Query Strings From Static Resources? Some servers and proxy servers are unable to cache query strings. So by removing them, you can sometimes improve your caching.

In this article, we’ll be discussing Why we should Remove Query Strings from Static Resources? How you can Remove Query Strings From Static Resources in WordPress so that can increases the speed of your WordPress Site or Blog?

Plugins Reviews remove query strings from static resources on GT metrix

Page load time is a very essential aspect for your website or blog. It also helps you to get higher ranking in Google Search. As Google had also announced  that page load time affect your search engine ranking.

As we know, Query Strings prevents Caching of Static Resources on Proxy servers and on browsers. By Removing Query Strings from Static Resources like CSS & JavaScript you can enable caching of static resources and can achieve an improvement in page load speed on speed analysis tool for websites.

Why you should Remove Query Strings from Static Resources ?

We know that Query Strings prevent caching of Static Resources like CSS and JavaScript on Proxy Servers and CDNs, which results slow loading speed of a website. So, you must have remove these Query Strings from Static Resources to enable caching on Proxy Servers. This will improve your cache performance and overall score in Google PageSpeed, Pingdom and GTmetrix

How to Remove Query Strings form Static Resources like CSS & JavaScript ?

Add the following code in your Appearance >> Editor >> functions.php file to Remove Query Strings form Static Resources

// Remove Query Strings From Static Resources in WordPress.

    function wordpress_remove_query_string($src) {
        $parts = explode('?', $src);
        return $parts[0];
    }

    /* Hook */
    add_filter('script_loader_src', 'wordpress_remove_query_string', 15, 1);
    add_filter('style_loader_src', 'wordpress_remove_query_string', 15, 1);

If you don’t want to add code in functions.php file then, another easiest way to remove query strings from static resources in WordPress is to use the free Query Strings Remover plugin.

Plugins Reviews remove Query Strings from Static Resources Plugin

This plugin removes query strings such as “?” or “&” in your URLS from all of your static resources, such as CSS and JavaScript.

Note: If you are using a CDN to deliver your assets, this might not be required as some CDN providers actually have the ability to cache query strings

I hope you liked my article, don’t forget to share it. you can also like my Facebook Page for WordPress latest updates & don’t forget to subscribe my Newsletter for instant updates. 🙂

  • 31
    Shares

Himani Bhardwaj

I Himani Bhardwaj founder of Plugins Reviews and also a Professional Developer. I'm a Passionate self-made Girl and plays an active role in the activities of WordPress Plugin Reviews I have also attended Chandigarh WordPress Meetup Sessions. I run an online website geared to help those who wants to Know about WordPress Topmost Plugins, Themes and also who wants to learn about PHP Concepts

This Post Has One Comment

  1. Good one!!

Leave a Reply

Close Menu