[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/js/ -> zxcvbn-async.js (source)

   1  /**
   2   * @output wp-includes/js/zxcvbn-async.js
   3   */
   4  
   5  /* global _zxcvbnSettings */
   6  
   7  /**
   8   * Loads zxcvbn asynchronously by inserting an async script tag before the first
   9   * script tag on the page.
  10   *
  11   * This makes sure zxcvbn isn't blocking loading the page as it is a big
  12   * library. The source for zxcvbn is read from the `_zxcvbnSettings` global.
  13   */
  14  ( () => {
  15      const asyncLoad = () => {
  16          if ( typeof _zxcvbnSettings === 'undefined' || ! _zxcvbnSettings.src ) {
  17              return;
  18          }
  19  
  20          const script = document.createElement( 'script' );
  21          script.src = _zxcvbnSettings.src;
  22          script.type = 'text/javascript';
  23          script.async = true;
  24  
  25          const first = document.getElementsByTagName( 'script' )[ 0 ];
  26          if ( ! first || ! first.parentNode ) {
  27              return;
  28          }
  29  
  30          first.parentNode.insertBefore( script, first );
  31      };
  32  
  33      window.addEventListener( 'load', asyncLoad );
  34  } )();


Generated : Thu Dec 3 08:20:02 2026 Cross-referenced by PHPXref