How to Remove Query Strings from Static Resources without a Plugin

()

To Remove Query Strings from Static Resources without a Plugin simply copy paste below code in your theme’s functions.php

//Remove Query Strings From Static Resources 
function smartwp_remove_query_strings_from_static_resources( $src ) {
 if( strpos( $src, '?v=' ) ){
 $src = remove_query_arg( 'v', $src );
 }
 if( strpos( $src, '?ver=' ) ){
 $src = remove_query_arg( 'ver', $src );
 }
 return $src;
}
add_filter( 'script_loader_src', 'smartwp_remove_query_strings_from_static_resources', 999 );
add_filter( 'style_loader_src', 'smartwp_remove_query_strings_from_static_resources', 999 );

Thats it now your static resources no longer have query strings attached to them!

How useful was this post?

Click on a star to rate it!

As you found this post useful...

Follow us on social media!

MUST READ  How to Manage an Outsourced Python Development Team Effectively

Share Ask

For paid sponsorship & partnership, email our board of admin at admin@share-ask.com , shareaskdotcom@gmail.com . Regards. :)

Leave a Reply