Load the WooCommerce Password Strength Meter Only When Needed
Removes the password strength meter script (about 400 KB with its dictionary) from every page except the account, checkout and password reset pages where customers actually choose a password.
Opens WPIDE on
Code
add_action( 'wp_print_scripts', function () {
if ( ! function_exists( 'is_account_page' ) ) {
return;
}
if ( is_account_page() || is_checkout() || ( isset( $_GET['action'] ) && 'rp' === $_GET['action'] ) ) {
return;
}
wp_dequeue_script( 'wc-password-strength-meter' );
wp_dequeue_script( 'password-strength-meter' );
wp_dequeue_script( 'zxcvbn-async' );
}, 100 );
Notes
The meter still appears on the pages where it is useful.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.