Making WordPress.org

#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
Cc:

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
14 months ago

  • Description modified (diff)

#2 @dd32
14 months ago

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

#4 @adamwood
14 months ago

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

After changing the script enqueueing from 'script' to 'viewScript' in https://github.com/WordPress/wporg-two-factor/issues/35, the dependencies are no longer loaded at all, resulting in a JS crash on the 2FA TOTP screen at https://wordpress.org/support/users/{username}/edit/account/?screen=totp

#5 @dd32
14 months ago

I've submitted a Gutenberg PR which resolves this: https://github.com/WordPress/gutenberg/pull/48268

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.


14 months ago

#7 @paulkevan
14 months ago

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

#8 @dd32
14 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 https://github.com/WordPress/wporg-two-factor/pull/66, and I've left https://github.com/WordPress/wporg-two-factor/pull/65 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.