Remove Version Query String From Static JS And CSS Files – WordPress Code Snippets

A website owner should always be trying to improve the speed of their website as much as possible. When you analyze your page using any page speed analyzer such as Page Speed, YSlow or Pingdom, you are very likely to see suggestions to remove query strings from static resources, such as Stylesheets and JavaScript files. This is a problem as many proxies will not cache the resources if it has a query string in the URL. A tip on the Google best practice pages is to remove all query strings from your static resources to enable proxy caching of the file. So in this article I will show you how you can easily remove version query string from static scripts and stylesheets.Most of the stylesheets and JavaScript files added by WordPress plugins and themes usually have version query string (?ver=) in their URL. And we want to remove version query string from these static resources to make our pages and static resource to cache so that the pages can load faster. There are a couple of plugins in WordPress respiratory that does this job but this is an easy enough task to use plugin.Just paste this following WordPress snippet in your theme’s functions.php file to remove version query string from static scripts and stylesheets resources. Once you are done adding this snippet in your theme, head back to analyze your page again and notice the difference.

 

// remove version query string from scripts and stylesheetsfunction wcs_remove_script_styles_version( $src ){ return remove_query_arg( ‘ver’, $src );}add_filter( ‘script_loader_src’, ‘wcs_remove_script_styles_version’ );add_filter( ‘style_loader_src’, ‘wcs_remove_script_styles_version’ );

Source: Remove Version Query String From Static JS And CSS Files – WordPress Code Snippets

Share:

Share on facebook
Facebook
Share on twitter
Twitter
Share on pinterest
Pinterest
Share on linkedin
LinkedIn

Social Media

Most Popular

Get The Latest Updates

Subscribe To Our Weekly Newsletter

No spam, notifications only about new products, updates.

Categories

On Key

Related Posts

Chavas Tacos – Mexican Food

Chava’s Tacos El Original is a Mexican Food Restaurant in the Chicago West side which is open 24hrs a day. The website was created on

TEJANOS CHICAGO – Event Space

TEJANOS CHICAGO started out as a Wix website with online ordering but when the restaurant acquired a Clover POS system the site move to WordPress.