Add Defer Attributes to WordPress Scripts with consistent versioning
Use the $wp_scripts, which is a global variable to get the version of a registered script. add_filter( ‘script_loader_tag’, ‘script_handler’, 10, 3 ); function script_handler( $tag, $handle, $src ) { // the following global contains all the information you need global $wp_scripts; $ver = $wp_scripts->registered[ $handle ]->ver; // do your thing } Note, this is exemplary.