WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

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

Was wondering if anyone knew of a way to remove the query string from external Javascript sources, such as Google's jQuery. Thanks in advance for any help

share|improve this question
up vote 3 down vote accepted

Filter 'script_loader_src', you get the source URL as first argument. Then run remove_query_arg() on this URL and return the shortened version.

Sample code:

add_filter( 'script_loader_src', 'remove_script_version_parameter' );

function remove_script_version_parameter( $src )
    return remove_query_arg( 'ver', $src );
share|improve this answer
I'm not exactly sure what you mean, but sounds like a solution. My thing is, I use CloudFlare, and I'm trying to remove the query code from their JS. Not really something im enqueueing or anything – Danny Michel Nov 23 '12 at 1:50
See my update. It work with enqueued scripts only. Hard coded scripts should never be used, because there is no API for these. – toscho Nov 23 '12 at 2:16

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.