Skip to content

Drop ready.js in 2.0 stable #302

Closed

Description

@klebba

Migration to the 2.0 release will require developers depending on etc/ready.js to crib the file into their project source. The code is trivial:

/**
 * Await document completeness. Will likely be replaced by built-in apis.
 * Check out https://github.com/Netflix/x-element/issues/65 for details.
 * @param {Document} target
 * @returns {Promise<any>}
 */
const ready = target => {
  return new Promise(resolve => {
    if (target.readyState === 'complete') {
      resolve(target);
    } else {
      const handle = evt => {
        if (evt.target.readyState === 'complete') {
          target.removeEventListener('readystatechange', handle);
          resolve(target);
        }
      };
      target.addEventListener('readystatechange', handle);
    }
  });
};

export default ready;

As browsers adopt CSS modules via with { type: css } import attributes, the need to use a DOMReady guard to skirt the Flash of Unstyled Content (FoUC) will finally pass. Instead we will use blocking="render" on imported custom elements. This allows the browser to wait until both JS and CSS content has loaded.

Activity

  1. klebba commented on Jun 26, 2025

    @klebba
    ContributorAuthor
  2. added a commit that references this issue on Jun 30, 2025
    97b80f6
  3. added a commit that references this issue on Jun 30, 2025
    b734ddc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions