By default, WordPress adds a version parameter to most of its JavaScript and CSS files, which looks something like this,
<link rel='stylesheet' href='http://www.yoursite.com/wp-content/themes/agentwp/style.css?ver=1.1.0' type='text/css' />
Here you can see the ?ver=1.1.0
parameter added at the end of style.css file.
The problem with the ver query string parameter is that it prevents the CSS and JS files from caching. Web browsers and CDN services will not cache any files that have a ver query string parameter added to them as they think that these files changes every time the page is loaded.
This will slow down your WordPress site as the browser will download a fresh copy of these CSS and JS files every time the page is loaded. If you test your website at Google PageSpeed Insights, Google will also tell you the same thing.
So, if your want to speed up your WordPress site, its best to remove the ver query string parameter from all your JS and CSS files in WordPress. To do this, add this code to the functions.php file of your WordPress theme,
if( strpos( $src, '?ver=' ) )
$src = remove_query_arg( 'ver', $src );
return $src;
}
add_filter( 'style_loader_src', 'remove_cssjs_ver', 10, 2 );
add_filter( 'script_loader_src', 'remove_cssjs_ver', 10, 2 );
This will remove the ver parameter from all the CSS and JS files on your site and the CSS and JS files will have no ver parameter,
<link rel='stylesheet' href='http://www.yoursite.com/wp-content/themes/agentwp/style.css' type='text/css' />
Update: Some WordPress plugins rely on the ver query string parameter for some internal maintenance. So removing it may cause issues with the functioning of those plugins. If adding the above code causes issues with any of the plugins on your site, then add this code instead,
if ( strpos( $src, 'ver=' . get_bloginfo( 'version' ) ) )
$src = remove_query_arg( 'ver', $src );
return $src;
}
add_filter( 'style_loader_src', 'vc_remove_wp_ver_css_js', 9999 );
add_filter( 'script_loader_src', 'vc_remove_wp_ver_css_js', 9999 );
This will only remove the ver parameter added by WordPress.