2

How do I fix this site speed recommendation with wordpress to remove query strings from static resources.

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:

http://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js?ver=4.5.3
/wp-content/cache/nextend/web/n2-ss-2/n2-ss-2.css?1467994835
/wp-content/cache/nextend/web/n2/n2.js?1467994835
/wp-content/plugins/smar ... edia/dist/smartslider-frontend.min.js?1467908685
/wp-content/plugins/smar ... artslider-simple-type-frontend.min.js?1467908685
/wp-content/plugins/smar ... nd/media/dist/nextend-frontend.min.js?1467908685
/wp-content/plugins/smar ... dia/dist/nextend-webfontloader.min.js?1467908685
/wp-content/themes/wootique-child/style.css?ver=4.5.3
/wp-content/themes/wootique/style.css?ver=4.5.3
/wp-includes/js/wp-embed.min.js?ver=4.5.3
/wp-includes/js/wp-emoji-release.min.js?ver=4.5.3

Wordpress seems to add these strings automatically.

3 Answers 3

5

this should do the job.. this removes the querystring on the frontend not the admin site.

Update: Add this into your functions.php file. Ensure that its kept within the PHP tags.

function rm_query_string( $src ){   
    $parts = explode( '?ver', $src );
    return $parts[0];
}

if ( !is_admin() ) {
    add_filter( 'script_loader_src', 'rm_query_string', 15, 1 );
    add_filter( 'style_loader_src', 'rm_query_string', 15, 1 );
}
Sign up to request clarification or add additional context in comments.

2 Comments

I tried this and installing plugins like "remove-query-strings-from-static-resources" and it works from browser inspector but Pingdoom and GTmetrix continues to show the suggestion "Remove query strings from static resources".
What if I want to remove query strings from a few resources, but not all?
0

This plugin will remove query strings from static resources like CSS & JS files, and will improve your speed scores in services like PageSpeed, YSlow, Pingdoom and GTmetrix.

Resources with a “?” or “&” in the URL are not cached by some proxy caching servers, and moving the query string and encode the parameters into the URL will increase your WordPress site performance significant.

1 Comment

Remove Query Strings From Static Resources Plugin
0
// Remove Query String
function nerodev_remove_query_string($src) {
    $parts = explode('?ver=', $src);
    return $parts[0];
}
add_filter('script_loader_src', 'nerodev_remove_query_string', 15, 1);
add_filter('style_loader_src', 'nerodev_remove_query_string', 15, 1);

I found this here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.