Remove Query Strings from Static Assets in WordPress Website

This article provides the required steps to remove query strings from static assets in WordPress websites.

Edit WordPress Theme functions.php File

Add the following code to the theme's functions.php file (located in /wp-content/themes/themename/ directory):


//remove query strings from static assets
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 );

Was this answer helpful?

 Print this Article

Also Read

Change the Nameservers Your Domain Points to in the Hosting Dashboard

This article will provide a guide for setting the nameservers your domain points to. Setting or...

508 Resource Limit is Reached

If your website is using a shared hosting acount, you may have noticed the following error...

What are the Performance Benefits of CloudLinux?

CloudLinux is the operating system used on the servers for shared hosting, reseller hosting,...

What are the Security Benefits of CloudLinux?

CloudLinux is the operating system used on the servers for shared hosting, reseller hosting,...

Clearing DNS Cache for Mac or Windows

Your DNS cache stores the locations (IP addresses) of web servers that contain web pages which...