Skip to content

Editorial cleanups to fetching scripts #7996

@domenic

Description

@domenic

https://html.spec.whatwg.org/#fetching-scripts was written some time ago, and is looking much harder to work with these days. It does not make good use of modern Infra constructs, and it has several unusual constructs such as unnamed, implicitly-threaded "perform the fetch" arguments, "asynchronous completions", etc.

Suggested changes, in rough order of most- to least-important:

  • Everything takes a (probably named) onComplete argument, to replace the current "asynchronous completion" paradigm. Yes, callers will have extra indentation. Oh well.
  • Make "perform the fetch" an optional named argument and thread it through explicitly.
    • Probably split up "fetch a classic worker-imported script"'s sync version from everyone else's async version.
    • Consider revising "is top-level" somehow, e.g. maybe we have two separate algorithms, or maybe we just make it clearer.
    • Consider whether we should merge modulepreload in Link header & early hints #7862's "top-level response" into this somehow. Probably at the very least we should state that they are mutually exclusive.
  • Use modern Fetch's callbacks. Notably processResponseConsumeBody is better than how we operate on the "body" concept.
  • Change all variables and parameters to use modern camelCasing style, instead of the current mix.
  • Consider adding types to all the parameter declarations, like most modern algorithms do.

Known callers of these algorithms: HTML itself, Service Workers, Import Maps.

/cc @noamr

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions