MPireDigital
6/13/2019 - 8:23 AM

WP Remove Query Strings


Important: Editing the source code of a WordPress theme could break your site if not done correctly. If you aren’t comfortable doing this, please check with a developer first. Or, you could also take advantage of the free Code Snippets plugin. This plugin will allow you to add the above code without having to worry if it will take your site down.

Simply create a new snippet and add the above code. Select “Only run on site front-end” and then save the snippet. Your query strings will then be gone! You might need to clear the cache on your WordPress site to see the changes take effect on the front-end.

Struggling with downtime and WordPress problems? Kinsta is the hosting solution designed to save you time! Check out our features
Remove query strings code snippet
Remove query strings code snippet

With Query Strings (Before Code)
Here is an example of scripts loading with query strings.

Requests with query strings
Requests with query strings

Without Query Strings (After Code)
Here is an example of scripts after having removed query strings.

Requests without query strings
Requests without query strings

2. Remove Query String from Static Resources with a Plugin
An alternative to using code is to use a WordPress performance plugin that has this feature built in. The premium Perfmatters plugin (developed by a team member at Kinsta), allows you to remove query strings from static resources with a click of a button. It also enables you to easily implement other optimizations for your WordPress site, and works alongside your current caching plugin.

Remove query strings with Perfmatters plugin
Remove query strings with Perfmatters plugin

No More Query Strings
After using either of the above options you should no longer see a warning about query strings in website speed test tools such as GTMetrix or Pingdom.

Fixed remove query strings from static resources warning
Fixed remove query strings from static resources warning

290
Shares