diff --git a/source b/source index 601171fa244..5e80fc32647 100644 --- a/source +++ b/source @@ -66070,11 +66070,12 @@ interface HTMLScriptElement : HTMLElement {

The second core attribute is the src attribute. It must only be specified for classic scripts and JavaScript module scripts, and denotes that instead of using the element's - child text content as the script content, the script will be fetched from the - specified URL. If src is specified, it must be - a valid non-empty URL potentially surrounded by spaces.

+ data-x="classic script">classic scripts, JavaScript + module scripts, and speculation rules, and + denotes that instead of using the element's child text content as the script content, + the script will be fetched from the specified URL. If src is specified, it must be a valid non-empty URL + potentially surrounded by spaces.

Which other attributes may be specified on a given script element is determined by the following table:

@@ -66143,7 +66144,17 @@ interface HTMLScriptElement : HTMLElement { · · - Speculation rules + External speculation rules + · + · + · + · + Yes + Yes + Yes + Yes + + Inline speculation rules · · · @@ -67046,15 +67057,14 @@ document.body.append(script1, script2);
  1. If el's type is "importmap" or "speculationrules", then queue an - element task on the DOM manipulation task source given el to - fire an event named error at el, and return.

    + data-x="">importmap", then queue an element task on the DOM + manipulation task source given el to fire + an event named error at el, and + return.

    -

    External import maps and speculation rules are not currently supported. See WICG/import-maps issue #235 and WICG/nav-speculation issue #348 - for discussions on adding support.

    +

    External import maps are not currently supported. See WICG/import-maps issue #235 for + discussions on adding support.

  2. Let src be the value of el's Fetch an external module script graph given url, settings object, options, and onComplete.

    + +
    "speculationrules"
    +
    +

    Fetch speculation rules given + url, el's node document, options, and the + following steps given speculationRulesText:

    + +
      +
    1. Let result be the result of parsing speculationRulesText given el's node + document.

    2. + +
    3. Run onComplete given result.

    4. +
    +

    For performance reasons, user agents may start fetching the classic script or module graph @@ -112625,7 +112650,7 @@ new PaymentRequest(…); // Allowed to use are delivered as JSON documents, via either:

      -
    • inline script elements with their type +

    • script elements with their type attribute set to "speculationrules"; or

    • resources fetched from a URL specified in the `Speculation-Rules` HTTP @@ -114366,37 +114391,15 @@ new PaymentRequest(…); // Allowed to use steps:

        -
      1. Let request be a new request whose - URL is url, destination is "speculationrules", and mode is - "cors".

      2. -
      3. -

        Fetch request with the following processResponseConsumeBody steps given response response and null, failure, or a - byte sequence bodyBytes:

        +

        Fetch speculation rules given + url, document, and the following steps given + speculationRulesText:

          -
        1. If bodyBytes is null or failure, then abort these steps.

        2. - -
        3. If response's status is - not an ok status, then abort these steps.

        4. - -
        5. If the result of extracting a MIME type - from response's header list - does not have an essence of - "application/speculationrules+json", then abort these steps.

        6. - -
        7. Let bodyText be the result of UTF-8 - decoding bodyBytes.

        8. - -
        9. Let ruleSet be the result of parsing a speculation rule set string given bodyText, - document, and response's URL. If this throws an exception, then abort these - steps.

        10. +
        11. Let ruleSet be the result of parsing speculationRulesText given document + and url.

        12. Append ruleSet to document's speculation rule @@ -117366,6 +117369,77 @@ document.querySelector("button").addEventListener("click", bound);

        +
        +

        To fetch speculation rules, given a URL url, + Document document, an optional script fetch options-or-null + options (default null), and an algorithm onComplete, run these steps. + onComplete must be an algorithm accepting a string.

        + +
          +
        1. +

          Let request be a new request, with

          + +
          +
          url
          +
          url
          + +
          destination
          +
          "speculationrules"
          + +
          mode
          +
          "cors"
          +
          +
        2. + +
        3. +

          If options is not null, then:

          + +
            +
          1. Set request's credentials + mode to options's credentials mode.

          2. + +
          3. Set request's integrity + metadata to options's integrity metadata.

          4. + +
          5. Set request's referrer + policy to options's referrer policy.

          6. + +
          7. Set request's priority to + options's fetch + priority.

          8. +
          +
        4. +
        5. +

          Fetch request with the following processResponseConsumeBody steps given + response and bodyBytes:

          + +
            +
          1. If bodyBytes is null or failure, then run onComplete given the + empty string, and return.

          2. + +
          3. If response's status is not an + ok status, then run onComplete given the empty string, and + return.

          4. + +
          5. If the result of extracting a MIME type from + response's header list does not + have an essence of + "application/speculationrules+json", then run onComplete given the + empty string, and return.

          6. + +
          7. Let speculationRulesText be the result of UTF-8 + decoding bodyBytes.

          8. + +
          9. Run onComplete given speculationRulesText.

          10. +
          +
        6. +
        +
        +
        Creating scripts