Title: Enqueue/register script &#8211; remove version # ?
Last modified: August 19, 2016

---

# Enqueue/register script – remove version # ?

 *  [misstee](https://wordpress.org/support/users/misstee/)
 * (@misstee)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/enqueueregister-script-remove-version/)
 * With wp_register_script, is it possible to remove (omit) the version number from
   the output? I’ve tried false, empty quotation marks, 0, and just leaving out 
   the variable altogether and the script output still inherits WP’s version, 2.7.

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [raskull](https://wordpress.org/support/users/raskull/)
 * (@raskull)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/enqueueregister-script-remove-version/#post-935693)
 * I need to know this too!
 * following this model:
    `wp_enqueue_style( $handle, $src, $deps, $ver, $media )`
 * yields this:
 * `wp_enqueue_style( 'mystyle', get_template_directory_uri() . '/mystyle.css', 
   false, false,'all' );`
 * which prints this no matter what:
 * `<link rel='stylesheet' id='mystyle-css' href='http://myplace.com/wp-content/
   themes/mytheme/mystyle.css?ver=2.8.4' type='text/css' media='all' />`
 * $ver as false prints ?ver=2.8.4
    $ver as ” prints ?ver=2.8.4 $ver as ‘foo’ prints?
   ver=foo hell, even $ver as foo (no quotes) prints ?ver=foo
 *  [Adam Harley (Kawauso)](https://wordpress.org/support/users/kawauso/)
 * (@kawauso)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/enqueueregister-script-remove-version/#post-935694)
 * The version number is included as part of the function so that if the script 
   or stylesheet is updated, the URL changes and caching mechanisms won’t serve 
   an old version.
 * That said, after having just poked around the deepest, darkest depths of the 
   script loader (and boy is that thing ridiculously complicated), it’s perfectly
   possible to take out with a couple of filters.
 *     ```
       <?
       /*
       Plugin name: Strip WP Version in Stylesheets/Scripts
       */
   
       add_filter( 'script_loader_src', 'remove_src_version' );
       add_filter( 'style_loader_src', 'remove_src_version' );
   
       function remove_src_version ( $src ) {
   
         global $wp_version;
   
         $version_str = '?ver='.$wp_version;
         $version_str_offset = strlen( $src ) - strlen( $version_str );
   
         if( substr( $src, $version_str_offset ) == $version_str )
           return substr( $src, 0, $version_str_offset );
         else
           return $src;
   
       }
   
       ?>
       ```
   
 * That was acting up for me, but I’m pretty sure that’s because I’m on a 2.9 dev
   build that does funky things with the `$wp_version`… like not having one. That
   should strip out the WordPress version from any stylesheets and scripts.
 *  [raskull](https://wordpress.org/support/users/raskull/)
 * (@raskull)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/enqueueregister-script-remove-version/#post-935695)
 * Wow, I haven’t had a chance to study this, and I never would have figured it 
   out myself, but that totally worked! Thanks!
 * Still the rhetorical question: isn’t $ver = false *supposed* to do away with 
   a version appendage?
 *  [Adam Harley (Kawauso)](https://wordpress.org/support/users/kawauso/)
 * (@kawauso)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/enqueueregister-script-remove-version/#post-935696)
 * It would make sense, but as far as the code is concerned that’s not a string,
   so it happily defaults to what it’s been told 🙂
 *  [Adam Harley (Kawauso)](https://wordpress.org/support/users/kawauso/)
 * (@kawauso)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/enqueueregister-script-remove-version/#post-935697)
 * Whoops. If anyone else reads this, that should open with `<?php` rather than `
   <?` or it won’t work on some setups. You can take out the `else` too, but that’s
   besides the point 🙂

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Enqueue/register script – remove version # ?’ is closed to new replies.

## Tags

 * [enqueue](https://wordpress.org/support/topic-tag/enqueue/)
 * [register](https://wordpress.org/support/topic-tag/register/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 3 participants
 * Last reply from: [Adam Harley (Kawauso)](https://wordpress.org/support/users/kawauso/)
 * Last activity: [16 years, 8 months ago](https://wordpress.org/support/topic/enqueueregister-script-remove-version/#post-935697)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
