Opened 8 months ago

Closed 7 months ago

#6770 closed defect (bug) (reported-upstream)

Don't enqueue zxcvbn.min.js when not needed

Reported by: jonoaldersonwp's profile jonoaldersonwp Owned by:
Milestone: Priority: high
Component: General Keywords: seo performance

Description (last modified by jonoaldersonwp)

Plugin and theme pages load /wp-includes/js/zxcvbn.min.js (via zxcvbn-async), which is nearly 400kb(!).

It seems that this is a password strength-o-meter, which almost certainly isn't used on the front end on these pages/templates.

Can this be dequeued/removed?

Change History (8)

#1 @jonoaldersonwp
8 months ago

  • Description modified (diff)

#2 @dd32
8 months ago

  • Resolution set to reported-upstream
  • Status changed from new to closed

#4 @adamwood
7 months ago

  • Resolution reported-upstream deleted
  • Status changed from closed to reopened

After changing the script enqueueing from 'script' to 'viewScript' in, the dependencies are no longer loaded at all, resulting in a JS crash on the 2FA TOTP screen at{username}/edit/account/?screen=totp

#5 @dd32
7 months ago

I've submitted a Gutenberg PR which resolves this:

In the meantime, Adding this code appears to work around it:

remove_filter( 'block_type_metadata', 'gutenberg_block_type_metadata_multiple_view_scripts' );
remove_filter( 'block_type_metadata_settings', 'gutenberg_block_type_metadata_view_script', 10, 2 );

As we're running WordPress 6.1, the viewScript functionality should be provided by core, so these filters shouldn't technically be needed, but I'm not 100% sure..

This ticket was mentioned in Slack in #meta by pkevan. View the logs.

7 months ago

#7 @paulkevan
7 months ago

I deployed the code above since users were unable to setup TOTP.

#8 @dd32
7 months ago

  • Resolution set to reported-upstream
  • Status changed from reopened to closed

re-closing this.

Another change was required to fix another breakage from the fix in, and I've left open to revert it all (and cause these JS libraries to always be loaded) if another breakage is encountered, until Gutenberg fixes it.

Note: See TracTickets for help on using tickets.