How to Remove Query Strings From Static Resources in WordPress

When you measure your websites speed with gtmetrix.com and pingdom.com, it shows  Remove Query Strings From Static Resources. So i give you solution to remove query strings from static resources from your WordPress site.

First of all What is Query String ??

A query string is a set of characters input to a computer or Web browser and sent to a query program to recover specific information from a database . On the Internet, a query string (also called an HTTP query string) is part of the set of characters automatically input in the address bar of a dynamic Web site when a user makes a request for information according to certain criteria. Source By:- Techtarget.com

In WordPress query string are changed all static resources like javascript, css, jquery  with the versions.

Example of Query String

remove query strings from static resources

In Example jquey ?ver= and css?ver= which we have to remove.

How to Remove Query Strings From Static Resources in WordPress ?

Removing query strings from static resources in wordpress is very easy just paste below code bottom in your themes function.php .

Now See the magic go gtmetrix.com and test your website speed.

Here is another Tricks for Increase WordPress Website Speed.

Subscribe

Subscribe and Get Free Daily Wordpress Tips and Tutorial Free!

About Mitul Shah

I just love to working with WordPress and i like to share my knowledge to all over world using this website hope my articles as help to build your blog powerful.

Comments

  1. Thanks Man… It works for me…

  2. nice trick. I’ve just tried to add a script from your. and the results were great. and is very useful for me. thank you

  3. Hi, when i added this :function _remove_script_version( $src ){
    $parts = explode( ‘?ver’, $src );
    return $parts[0];
    }
    add_filter( ‘script_loader_src’, ‘_remove_script_version’, 15, 1 );
    add_filter( ‘style_loader_src’, ‘_remove_script_version’, 15, 1 );

    To my functionS.php my site was dropping 20% in GTMETRIX????

    Im using wordpress and genesis (only)

  4. Hi,

    when I added the coce nothing happend?

    I’m doing something wrong

    Grtz Dimitri

  5. Hi,

    I added the code, but the score is identical with or without the code. I add the code, then clear the cache, but nothing.

    I also tried the plugin, but that didn’t help either. Maybe you can check my site?

    Thanks

  6. Yes I use W3 and I clear the Cache every time I make changes, but nothing?

  7. saurabh patel says:

    Excellent ….job sir……

  8. Thank you so much, I just add your code into my website function.php file and boom. All “Remove query strings from static resources” problems are solved. Thank again.

  9. Wow great code Mitul! I just popped it in the bottom of functions.php in Divi theme and it knocked out all query string warnings from GTmetrix and dropped a second off page load time!

    Thank you!

  10. Christopher says:

    This worked perfectly. Used it with Genesis 2.0 and Agency Pro theme. Thanks!

  11. Hm 🙁 tried for hours to find a good code, but nothing’s helping

    see this: http://gtmetrix.com/reports/cherrykoks.de/L3KqEFOl

    I use w3 cache and cloudflare free account. (if that helps)

    posted the code at the end of the functions.php – nothing 🙁

  12. You are brilliant, this works great, thank you so much for taking the time to make this tutorial

Tell us what you're thinking...

All comments are moderated.

* Denotes required field.

*

Notify via Email Only if someone replies to My Comment