As you know zxcvbn.min.js is around 400kb and loaded by default in wordpress websites , I want to know how I can prevent this JavaScript library to load As I don\'t want passwo
The previous answer didn't worked for me, maybe because I usewp_enqueue_scripts
so here is my setup that got me rid of the wc-password-strength-meter
:
function my_add_frontend_scripts() {
// Deregister script about password strenght meter ~ 800kb
wp_dequeue_script('wc-password-strength-meter');
wp_deregister_script('wc-password-strength-meter');
wp_register_script('custom-script', get_stylesheet_directory_uri().'/custom-script.js', array('jquery'), 1, false );
wp_enqueue_script('custom-script');
}
add_action('wp_enqueue_scripts', 'my_add_frontend_scripts');
This code in my theme function.php worked for me:
/**
* Deregister scripts
*/
function deregister_or_dequeue_scripts() {
wp_dequeue_script('wc-password-strength-meter');
}
add_action('wp_print_scripts', 'deregister_or_dequeue_scripts', 20);
It will remove wc-password-strength-meter
javascript and all its dependences (including zxcvbn.min.js
).
Add the following to your theme's function.php or to a custom plugin:
//disable zxcvbn.min.js in wordpress
add_action('wp_print_scripts', 'remove_password_strength_meter');
function remove_password_strength_meter() {
// Deregister script about password strenght meter
wp_dequeue_script('zxcvbn-async');
wp_deregister_script('zxcvbn-async');
}
So far the wp_enqueue_scripts code is the only solution that actually succeeded in removing the password strength meter files from being loaded. Total page size decreased by about 400KB which was awesome. (841KB to 439KB)
The problem is adding that code to my functions.php actually slowed down the load time... It caused a 404 error and WebPageTest shows TTFB for that file itself was 900ms after multiple trials.
On one hand I'm encouraged that something actually blocked the Javascript from being loaded and the total site size being cut in half. On the other hand the code you supplied slowed my site down (from 404 error and TTFB 900ms)
I just can't believe Wordpress doesn't have a built in option to completely disable this in the admin dashboard. I'm not talking about blocking PW Java from loading on some pages, im saying COMPLETELY GONE.
If you are the sole user/admin/owner of your website (an don't allow anyone to register) and aren't dumb enough to make your password "1234" there is absolutely no point in having a pw strength meter. It results a big page size and slower load time. My site is 841KB and 400KB is the stupid pw strength meter. So frustrating!
There are literally thousands of people searching for this solution.
-cal
404 error & TTFB