WordPress – Disable Javascript Versions

WordPress - General Functions Javascript PHP

Snippet Overview

WordPress – Disable Javascript Versions

By default WordPress adds dynamic versioning to Javascript files when rendering those files in the DOM. Although this can be handy, in some instances you might want to remove this versioning. To do this add the code below to your theme’s functions.php file.

# Remove JS Versions

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 );
0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply