Technology Bites

  • Home
  • Tech
    • Software
    • Browsers
    • Google
    • Internet
    • Windows
  • Mobile
    • Android
    • Apple
    • Windows Phone
  • Products
    • Phones
    • Tablets
  • TIP US
You are here: Home / Other / Remove WordPress version number and query strings from CSS and JS files

Remove WordPress version number and query strings from CSS and JS files

If you use WordPress you know that WordPress adds a generator meta tag with the version number on the head section of the source code. Also some CSS and JS files also add a query string at the end of the file name, the query string can be the version number of the file. The problem with query strings added like this is some browsers and proxy servers like Varnish don’t cache them, some CDNs also don’t cache files with query string.

It is possible to remove this version numbers and query strings from outputting into the HTML. It also serves a purpose by adding basic protection from prying eyes.

To remove the WordPress generator tag with version number, place the below code in your theme functions.php. This will only remove the tag from html pages, if you want to remove it completely, for example from RSS feeds as well you need to adda filter to do that.
[php]remove_action( ‘wp_head’, ‘wp_generator’ );[/php]
To remove version number from CSS and JS file paste the below code in your theme functions.php file.
[php]// remove query strings from any enqueued scripts
function vc_remove_wp_ver_css_js( $src ) {
if ( strpos( $src, ‘ver=’ ) )
$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 );[/php]

Reference

Share this:

  • Tweet

Related

About Ram

I am a blogger and Technology Enthusiast. I write about software, tech news, gadgets. You can reach me at ram@teknobites.com, follow me on Google+ or on Twitter

« Google Now for iOS is demoed in a leaked video
Samsung Galaxy SIII Refresh coming with bigger battery, wireless charging »

Top Posts

  • How to Sync MS Office documents with Google Docs
  • Cyanogenmod ROM: Overview and Features
  • Samsung Galaxy S5 may not include QHD display, eye scanner
  • Sony to update Xperia devices to Android 4.3 Jelly Bean
  • SugarSync: File Syncing Across Multiple Devices (3 Accounts Giveaway)
  • Microsoft announces Windows Phone 8.1 with Cortana, Action Center and more
  • Karbonn A1 star and Karbonn A5 star are available online now for Rs. 3514 and Rs 4890
  • New Nexus 7 2013 is now available in UK, Europe and Japan
  • How to Extract Wallpapers from Windows Themes
  • Xolo A500S launched with 1.2Ghz Dual Core, Android 4.2, 4-inch display for Rs. 6999

About Us · Archive · Disclaimer & Privacy Policy · TIP US · Copyright © 2026 · Technology Bites