Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.