Reputation: 21
The file /zxcvbn.min.js appears to be related to a password strength tool. Which is great, but it's causing issues in Google Pagespeed score (because it's not being pulled by the CDN), and when I use the Chrome developer network tool, I don't even see it.
I can see that it's being loaded by the script-loader.php file, but I'm not familiar enough with php to know how to change it to pull from the cdn rather than the main domain.
Here is the code I'm seeing in the script-loader.php file:
$scripts->add( 'zxcvbn-async', "/wp-includes/js/zxcvbn-async$suffix.js", array(), '1.0' );
did_action( 'init' ) && $scripts->localize( 'zxcvbn-async', '_zxcvbnSettings', array(
'src' => empty( $guessed_url ) ? includes_url( '/js/zxcvbn.min.js' ) : $scripts->base_url . '/wp-includes/js/zxcvbn.min.js',
) );
Can someone help me out here?
Upvotes: 2
Views: 646
Reputation: 21
My theme uses wp_enqueue_scripts so here is my setup that got me rid of the excessively heavyweight wc-password-strength-meter
.
Adding this to functions.php successfully removes the password strength meter (my problem is it really slows down my TTFB (900ms) and causes a 404 error!)
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');
Upvotes: 1