Genesis Themes

  • Home
  • Genesis Tutorials
  • WP Tutorial
  • Twenty Fifteen Theme
  • Social Media
  • WP Plugins

Remove Query String from Static Resources in WordPress

Easily remove query string from static resources : By default WordPress generates query strings for static resources like CSS,JavaScript and jQuery URL's.We are listing 2 amazing methods to remove query strings from static resources in WordPress by editing theme's functions.php file and W3 total cache settings.Resources with a “?” or “&” in the URL are not cached by most of the proxy servers and affects on page load time.The best solution is you must remove the query string from URL.

Remove Query Strings from static resources in WordPress

Pingdom, Google's page speed insights , Gtmetrix and Yahoo's Yslow recommends you to remove query string from static resources to speed up WordPress blog.As we discussed above by default WordPress will generate query strings to show the version number of static resources. WordPress theme, Plugin contains CSS, JavaScript and jQuery files, for each file WordPress produces a version number.

You may have experienced in WordPress with "?" query string from URL.To remove query strings from static resources in WordPress, add the following code snippet to your wordpress theme's functions.php file.

Go to Appearcence > Editor > Functions.php, and paste the following code at the end of your file.

function _remove_script_version( $src ){
$parts = explode( '?', $src );
return $parts[0];
}
add_filter( 'script_loader_src', '_remove_script_version', 15, 1 );
add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );

Note: It's not possible to remove the query string from Google Analytics and Adsense because these ads are served from their own host.You can't do anything about it.

Remove Query String from static resources with W3 Total Cache plugin

It can also be done with W3 total cache plugin.Just follow the tutorial to remove query string from static resources URL with the best W3 total cache settings.

Go to Performance > Browser Cache and look for Prevent caching of objects after settings change.This can be found under General and CSS/JS files section.Uncheck this option to completely remove query strings from static resources.if you enable this option,then W3 total cache will generate a new query and appended to objects allowing the new policy to be applied.

General :Uncheck-Prevent caching of objects after settings change.

CSS/JS : Uncheck-Prevent caching of objects after settings change.

That's it, if you found any difficulty to remove query strings from your WordPress site, let me know.

Related Posts

  • Related Posts by Category in WordPress without Plugin
  • Top 10 Most Popular Google Adsense Alternatives 2016
  • Specify a Vary: Accept-Encoding header in WordPress
  • Manually Display Disqus Comment Count in WordPress
  • How to Minimize DNS Lookups
  • How to Avoid Landing Page Redirects in WordPress
  • How to Disable Emojicons in WordPress 4.2
  • How to Inline Small JavaScript Files
  • How to Add WordPress Related Posts Without Plugin
  • Show one category Posts on Home Page in WordPress 2015 theme

Bluehost and Siteground Coupons for January 2016.

Best Premium WordPress Themes from TemplateMonster
download wordpress themes from MonsterOne

Categories

  • Blog
  • Blogger
  • Genesis Tutorials
  • Social Media
  • Top Websites
  • Twenty Fifteen WordPress Theme
  • WordPress Plugins
  • WordPress Tutorial