WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm getting nags on google speed test regarding the querystrings in my scripts. So, I'm trying to remove them by passing false as the argument for that parameter. However, it does not seem to have effect:

wp_register_script('myscript', get_bloginfo('template_directory').'/scripts.myversionnumber.js',false,false,true);

PS: the "myversionnumber" part of the js filename is my means of controlling cache/versioning rather than the ?ver= approach which apparently trips up some proxy servers (according to Google pagespeed test):

Remove query strings from static resources Enabling public caching in the HTTP headers for static resources allows the browser to download resources from a nearby proxy server rather than from a remote origin server. Learn more

Suggestions for this page

Resources with a "?" in the URL are not cached by some proxy caching servers. Remove the query string and encode the parameters into the URL for the following resources:

share|improve this question
Interesting question, never knew that query strings would trip up page speed. While I don't have a solution, lemme comment on setting the parameter to "false": Afaik, you either enter a version number, or it defaults to the current wordpress version. – Johannes Pille May 17 '12 at 16:15
I thought that the script would be cached, even with a version number - and that altering the version number would 'break' the cache, purposefully so that the new, rather than old, script would be loaded.... – Stephen Harris May 17 '12 at 18:37
@Stephen, that's the idea exactly. However, apparently some proxy cache servers will not cache resource URLs with querystring params. That's why I'm opting to encode the params in the filename instead. Same effect, less baggage. – Scott B May 18 '12 at 13:15
Hello Scott B. I am facing the same problem. After I run a test on gtmetrix I am getting errors for the query. Did the solution provided by @SickHippie work for you? Is it safe to use it? – kat_indo Nov 3 '13 at 20:16
up vote 8 down vote accepted

I think you have to pass NULL as the 4th parameter.

share|improve this answer

You can pass null as the version value to wp_register_script or wp_enqueue_script and it should drop the query string.

share|improve this answer


I solved this a lot differently from SickHippie and chrisguitarguy and I guess it's not the way it is supposed to be solved, but it's working really good for me.

The code...

I put this snippet of code at the end of my theme's functions.php file:

function remove_cssjs_querystring( $src ) {
  if( strpos( $src, '?rev=' ) ) // copy/paste this line and the next one to take away what you want from the end of your css/js
    $src = remove_query_arg( 'rev', $src );
  if( strpos( $src, 'ver=' ) )
    $src = remove_query_arg( 'ver', $src );
  return $src;
add_filter( 'style_loader_src', 'remove_cssjs_querystring', 10, 2 );
add_filter( 'script_loader_src', 'remove_cssjs_querystring', 10, 2 );

Where the idea came from...

I was loooking for it on Google and I found this article, but I kept having a problem with css/js: at this point my code still had (here and there) at the end something like .../some-stylesheet.css?rev=... and I thought about extending the code snippet a little bit to include anything that could have been after .css.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.