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

1 Answer 1


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 );
  • 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 Nov 23, 2012 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.
    – fuxia
    Nov 23, 2012 at 2:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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