Improving WordPress Performance

Remove query strings from static resources

CSS and JavaScript files may have the file version on the end of their URLs, such as domain.com/style.css?ver=4.6. Some servers and proxy servers are unable to cache query strings, even if a cache-control:public header is present. So by removing them, this will improve caching. This will also fix that warning you see in Pingdom and GTMetrix called “Remove query strings from static resources.”

To remove Query Strings:

Edit the functions.php file of the active theme with the code below:

//* Remove Query String from Static Resources
function _remove_script_version( $src ){
$parts = explode( ‘?ver’, $src );
return $parts[0];
}
add_filter( ‘script_loader_src’, ‘_remove_script_version’, 15, 1 );
add_filter( ‘style_loader_src’, ‘_remove_script_version’, 15, 1 );

See this helpful article from KeyCdn

Minify JavaScript and CSS

See this helpful article from Technumero

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.