diff --git a/source b/source index e08cc11ae40..1ca63722011 100644 --- a/source +++ b/source @@ -63803,11 +63803,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:

@@ -63876,7 +63877,17 @@ interface HTMLScriptElement : HTMLElement { · · - Speculation rules + External speculation rules + · + · + · + · + Yes + Yes + Yes + Yes + + Inline speculation rules · · · @@ -64744,15 +64755,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"
    +
    +
      +
    1. Let speculationRulesText be the result of fetching speculation rules given url and + document.

    2. + +
    3. Let result be the result of creating a speculation rules parse result given + speculationRulesText and document.

    4. + +
    5. Run onComplete given result.

    6. +
    +

    For performance reasons, user agents may start fetching the classic script or module graph @@ -108688,7 +108713,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 @@ -110404,45 +110429,19 @@ 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. Let speculationRulesText be the result of fetching speculation rules given url and + document.

      4. -
      5. -

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

        - -
          -
        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 + speculationRulesText, document, and url.

        10. -
        11. 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.

        12. +
        13. Append ruleSet to + document's speculation rule + sets.

        14. -
        15. Append ruleSet to - document's speculation rule - sets.

        16. - -
        17. Consider speculative loads for document.

        18. -
        -
      6. +
      7. Consider speculative loads for document.

@@ -113277,6 +113276,40 @@ document.querySelector("button").addEventListener("click", bound); pass it along as well.

+

To fetch speculation rules, given a URL url and + Document document, run these steps. + +

    +
  1. Let request be a new request whose URL is url, client is document's relevant settings + object, 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:

    + +
      +
    1. If bodyBytes is null or failure, then return the empty string.

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

    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 return the empty string.

    6. + +
    7. Return the result of UTF-8 decoding + bodyBytes.

    8. +
    +
  4. +
+
Creating scripts

To create a classic script, given a