From f8b1b09f47354b24e3d59cc5fafb0654d1b89f93 Mon Sep 17 00:00:00 2001 From: Steven Date: Sun, 14 Sep 2025 22:21:35 -0400 Subject: [PATCH 01/12] add import bytes --- source | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 66 insertions(+), 5 deletions(-) diff --git a/source b/source index bf6b1fb9326..d985b9313d9 100644 --- a/source +++ b/source @@ -64211,6 +64211,21 @@ o............A....e response has a MIME type that is not a JavaScript MIME type.

+
+

The following sample shows how a bytes module script can be imported from inside + a JavaScript module script:

+ +
<script type="module">
+ import logoBytes from "https://resources.whatwg.org/logo.png" with { type: "bytes" };
+
+ console.log("Binary data length:", logoBytes.byteLength);
+</script>
+ +

The Bytes module script will return a Uint8Array object containing + the raw bytes of the fetched resource. Unlike JSON module scripts + which require a specific MIME type, bytes modules can be used to import binary data from any resource.

+
+
Processing model
@@ -112104,7 +112119,7 @@ document.querySelector("button").addEventListener("click", bound); script">JavaScript module scripts;

  • a Synthetic Module Record, for CSS module - scripts and JSON module scripts;

  • + scripts, JSON module scripts, and Bytes module scripts;

  • a WebAssembly Module Record, for WebAssembly module scripts; or

  • @@ -112206,6 +112221,20 @@ document.querySelector("button").addEventListener("click", bound); --> +
  • +

    A module script is a Bytes module script if its record is a Synthetic Module Record, and it + was created via the create a Bytes module + script algorithm. Bytes module scripts represent binary data as Uint8Array backed by + an immutable ArrayBuffer.

    + + +
  • +
  • A module script is a WebAssembly module script if its record is a WebAssembly Module @@ -112213,11 +112242,11 @@ document.querySelector("button").addEventListener("click", bound);

  • -

    As CSS style sheets and JSON documents do not import dependent modules, and do not +

    As CSS stylesheets, JSON documents, and binary data do not import dependent modules, and do not throw exceptions on evaluation, the fetch options and base URL of CSS module scripts and JSON module - scripts and are always null.

    + module script">CSS module scripts, JSON module + scripts, and Bytes module scripts are always null.

    The active script is determined by the following algorithm:

    @@ -113112,6 +113141,10 @@ document.querySelector("button").addEventListener("click", bound); settingsObject, response's URL, and options.

    +
  • If moduleType is "bytes", then set moduleScript to + the result of creating a Bytes module script given bodyBytes and + settingsObject.

  • +
  • Otherwise:

      @@ -113432,6 +113465,31 @@ document.querySelector("button").addEventListener("click", bound);
    1. Return script.

    +

    To create a Bytes module script, given a + byte sequence bytes and an environment settings object settings:

    + +
      +
    1. Let script be a new module script that this algorithm will + subsequently initialize.

    2. + +
    3. Set script's settings + object to settings.

    4. + +
    5. Set script's base URL and + fetch options to null.

    6. + +
    7. Set script's parse error and + error to rethrow to null.

    8. + +
    9. Let result be a new Uint8Array object, in settings's + realm, whose backing bytes are bytes.

    10. + +
    11. Set script's record to the result + of CreateDefaultExportSyntheticModule(result).

    12. + +
    13. Return script.

    14. +
    +

    The module type from module request steps, given a ModuleRequest Record moduleRequest, are as follows:

    @@ -113467,7 +113525,7 @@ document.querySelector("button").addEventListener("click", bound);
    1. If moduleType is not "javascript-or-wasm", "css", or "json", then return false.

    2. + data-x="">css", "json", or "bytes", then return false.

    3. If moduleType is "css" and the CSSStyleSheet interface is not exposed in @@ -113488,6 +113546,9 @@ document.querySelector("button").addEventListener("click", bound);

    4. If moduleType is "css", then return "style".
    5. +
    6. If moduleType is "bytes", then return "empty".
    7. +
    8. Return defaultDestination.
    From 183a2cef491547552e4c4aca88c65164a171d26d Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 16 Sep 2025 19:56:13 -0400 Subject: [PATCH 02/12] make "bytes module script" lowercase --- source | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/source b/source index d985b9313d9..d14a21da05b 100644 --- a/source +++ b/source @@ -64221,7 +64221,7 @@ o............A....e console.log("Binary data length:", logoBytes.byteLength); </script> -

    The Bytes module script will return a Uint8Array object containing +

    The bytes module script will return a Uint8Array object containing the raw bytes of the fetched resource. Unlike JSON module scripts which require a specific MIME type, bytes modules can be used to import binary data from any resource.

  • @@ -112119,7 +112119,7 @@ document.querySelector("button").addEventListener("click", bound); script">JavaScript module scripts;

  • a Synthetic Module Record, for CSS module - scripts, JSON module scripts, and Bytes module scripts;

  • + scripts, JSON module scripts, and bytes module scripts;

  • a WebAssembly Module Record, for WebAssembly module scripts; or

  • @@ -112222,15 +112222,15 @@ document.querySelector("button").addEventListener("click", bound);
  • -

    A module script is a Bytes module script if its A module script is a bytes module script if its record is a Synthetic Module Record, and it - was created via the create a Bytes module - script algorithm. Bytes module scripts represent binary data as Uint8Array backed by + was created via the create a Bytes module + script algorithm. bytes module scripts represent binary data as Uint8Array backed by an immutable ArrayBuffer.

  • @@ -112246,7 +112246,7 @@ document.querySelector("button").addEventListener("click", bound); throw exceptions on evaluation, the fetch options and base URL of CSS module scripts, JSON module - scripts, and Bytes module scripts are always null.

    + scripts, and bytes module scripts are always null.

    The active script is determined by the following algorithm:

    @@ -113142,7 +113142,7 @@ document.querySelector("button").addEventListener("click", bound); data-x="concept-response-url">URL, and options.

  • If moduleType is "bytes", then set moduleScript to - the result of creating a Bytes module script given bodyBytes and + the result of creating a bytes module script given bodyBytes and settingsObject.

  • @@ -113465,7 +113465,7 @@ document.querySelector("button").addEventListener("click", bound);
  • Return script.

  • -

    To create a Bytes module script, given a +

    To create a bytes module script, given a byte sequence bytes and an environment settings object settings:

      From b894372e009a0cc1a874d86618a6cb4c00aaba40 Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 16 Sep 2025 20:03:03 -0400 Subject: [PATCH 03/12] add references to Uint8Array & ArrayBuffer --- source | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source b/source index d14a21da05b..a60032b9f7b 100644 --- a/source +++ b/source @@ -112224,9 +112224,9 @@ document.querySelector("button").addEventListener("click", bound);
    1. A module script is a bytes module script if its record is a Synthetic Module Record, and it - was created via the create a Bytes module - script algorithm. bytes module scripts represent binary data as Uint8Array backed by - an immutable ArrayBuffer.

      + was created via the create a bytes module + script algorithm. bytes module scripts represent binary data as Uint8Array + backed by an immutable ArrayBuffer.

    2. From e5b97571bff570038668f31bebe4111ef0c4418f Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 16 Sep 2025 20:04:46 -0400 Subject: [PATCH 05/12] "stylesheets" => "style sheets" --- source | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source b/source index 1d3f4b2c73a..d7a89eb41ec 100644 --- a/source +++ b/source @@ -112236,7 +112236,7 @@ document.querySelector("button").addEventListener("click", bound);
    3. -

      As CSS stylesheets, JSON documents, and binary data do not import dependent modules, and do not +

      As CSS style sheets, JSON documents, and binary data do not import dependent modules, and do not throw exceptions on evaluation, the fetch options and base URL of CSS module scripts, JSON module From 98286550611bd8ecb13ad526092288689baa5405 Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 16 Sep 2025 20:22:23 -0400 Subject: [PATCH 06/12] add ref to JSIMPORTBYTES --- source | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/source b/source index d7a89eb41ec..ac38ed953aa 100644 --- a/source +++ b/source @@ -113478,12 +113478,17 @@ document.querySelector("button").addEventListener("click", bound);

    4. Let result be a new Uint8Array object, in settings's realm, whose backing bytes are bytes.

    5. -
    6. Set script's record to the result - of CreateDefaultExportSyntheticModule(result).

    7. +
    8. Let record be CreateBytesModule(immutableBytes).

    9. + + JSIMPORTBYTES +
    10. Set script's record to record.

    11. Return script.

    +

    User agents that support JavaScript must also implement the Import Bytes proposal. + The following terms are defined there, and used in this specification: JSIMPORTBYTES

    +

    The module type from module request steps, given a ModuleRequest Record moduleRequest, are as follows:

    @@ -150230,6 +150235,9 @@ INSERT INTERFACES HERE
    [JSINTL]
    ECMAScript Internationalization API Specification. Ecma International.
    +
    [JSIMPORTBYTES]
    +
    Import Bytes. Ecma International.
    +
    [JSON]
    The JavaScript Object Notation (JSON) Data Interchange Format, T. Bray. IETF.
    From 9896faa405bc13e9b2483bd40065e9b41275ee83 Mon Sep 17 00:00:00 2001 From: Steven Date: Wed, 24 Dec 2025 12:43:41 -0500 Subject: [PATCH 07/12] Apply suggestions from annevk --- source | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source b/source index ac38ed953aa..174be899bdc 100644 --- a/source +++ b/source @@ -64223,7 +64223,7 @@ o............A....e

    The bytes module script will return a Uint8Array object containing the raw bytes of the fetched resource. Unlike JSON module scripts - which require a specific MIME type, bytes modules can be used to import binary data from any resource.

    + which require a specific MIME type, bytes module scripts can be used to import binary data from any resource.

    @@ -112225,7 +112225,7 @@ document.querySelector("button").addEventListener("click", bound);

    A module script is a bytes module script if its record is a Synthetic Module Record, and it was created via the create a bytes module - script algorithm. bytes module scripts represent binary data as Uint8Array + script algorithm. Bytes module scripts represent binary data as Uint8Array backed by an immutable ArrayBuffer.

    From 2c529f961e190f04f52e81eb3ce4d04c19540677 Mon Sep 17 00:00:00 2001 From: Steven Date: Wed, 24 Dec 2025 12:46:25 -0500 Subject: [PATCH 08/12] Move `If moduleType is bytes` above `Let referrerPolicy be the result of` per nicolo-ribaudo --- source | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source b/source index 174be899bdc..1228efab305 100644 --- a/source +++ b/source @@ -113120,6 +113120,10 @@ document.querySelector("button").addEventListener("click", bound);
  • Let moduleScript be null.

  • +
  • If moduleType is "bytes", then set moduleScript to + the result of creating a bytes module script given bodyBytes and + settingsObject.

  • +
  • Let referrerPolicy be the result of parsing the `Referrer-Policy` header given response. REFERRERPOLICY

  • @@ -113135,10 +113139,6 @@ document.querySelector("button").addEventListener("click", bound); settingsObject, response's URL, and options.

    -
  • If moduleType is "bytes", then set moduleScript to - the result of creating a bytes module script given bodyBytes and - settingsObject.

  • -
  • Otherwise:

      From 72f4bc020de2ea1a890867387ee0b7421793ace2 Mon Sep 17 00:00:00 2001 From: Steven Date: Thu, 25 Dec 2025 16:35:55 -0500 Subject: [PATCH 09/12] Move `JSIMPORTBYTES` --- source | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source b/source index 1228efab305..8d58298ed42 100644 --- a/source +++ b/source @@ -113478,9 +113478,8 @@ document.querySelector("button").addEventListener("click", bound);
    1. Let result be a new Uint8Array object, in settings's realm, whose backing bytes are bytes.

    2. -
    3. Let record be CreateBytesModule(immutableBytes).

    4. +
    5. Let record be CreateBytesModule(immutableBytes). JSIMPORTBYTES

    6. - JSIMPORTBYTES
    7. Set script's record to record.

    8. Return script.

    9. From e780b8b296a3656f84ac183a4e711b0ee3741fd0 Mon Sep 17 00:00:00 2001 From: Steven Date: Thu, 25 Dec 2025 16:38:48 -0500 Subject: [PATCH 10/12] fix indent --- source | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source b/source index 8d58298ed42..9c981f66fa6 100644 --- a/source +++ b/source @@ -113486,7 +113486,7 @@ document.querySelector("button").addEventListener("click", bound);

    User agents that support JavaScript must also implement the Import Bytes proposal. - The following terms are defined there, and used in this specification: JSIMPORTBYTES

    + The following terms are defined there, and used in this specification: JSIMPORTBYTES

    The module type from module request steps, given a ModuleRequest Record moduleRequest, are as follows:

    From 8cf14bf417943ce828df2a3d768a11629be66b4c Mon Sep 17 00:00:00 2001 From: Steven Date: Sun, 25 Jan 2026 15:44:29 -0500 Subject: [PATCH 11/12] apply suggestions from annevk --- source | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source b/source index 9c981f66fa6..e646750f97c 100644 --- a/source +++ b/source @@ -112119,7 +112119,8 @@ document.querySelector("button").addEventListener("click", bound); script">JavaScript module scripts;

  • a Synthetic Module Record, for CSS module - scripts, JSON module scripts, and bytes module scripts;

  • + scripts, JSON module scripts, and bytes module scripts;

  • a WebAssembly Module Record, for WebAssembly module scripts; or

  • @@ -112236,7 +112237,7 @@ document.querySelector("button").addEventListener("click", bound); -

    As CSS style sheets, JSON documents, and binary data do not import dependent modules, and do not +

    As CSS style sheets, JSON documents, and plain data do not import dependent modules, and do not throw exceptions on evaluation, the fetch options and base URL of CSS module scripts, JSON module From ef8b0c0bc11edc6ba4bbc2ff3476def10d6abb91 Mon Sep 17 00:00:00 2001 From: Steven Date: Sun, 25 Jan 2026 15:45:58 -0500 Subject: [PATCH 12/12] Number of raw bytes --- source | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source b/source index e646750f97c..ce16ab451e2 100644 --- a/source +++ b/source @@ -64218,7 +64218,7 @@ o............A....e

    <script type="module">
      import logoBytes from "https://resources.whatwg.org/logo.png" with { type: "bytes" };
     
    - console.log("Binary data length:", logoBytes.byteLength);
    + console.log("Number of raw bytes:", logoBytes.byteLength);
     </script>

    The bytes module script will return a Uint8Array object containing