Skip to content

Commit 83fac47

Browse files
committed
Show WASM binary size in playground loading message
1 parent 965c898 commit 83fac47

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

static/js/wasm-terminal.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ let cursorPos = 0;
6363
let history = [];
6464
let historyIndex = -1;
6565
let wasmReady = false;
66+
let wasmSize = 0; // downloaded binary size in bytes
6667
let persistentDir = null;
6768
let cwd = ""; // virtual current working directory (relative to preopened root)
6869
let currentLocale = "en-US"; // current locale for l10n
@@ -109,6 +110,8 @@ async function loadWasm() {
109110
if (!response.ok) {
110111
throw new Error(`Failed to fetch WASM binary: ${response.status}`);
111112
}
113+
const contentLength = response.headers.get("content-length");
114+
if (contentLength) wasmSize = parseInt(contentLength, 10);
112115
// compileStreaming requires application/wasm content-type; fall back if not set.
113116
// Clone the response so the fallback path can read the body without re-fetching.
114117
const cloned = response.clone();
@@ -733,7 +736,8 @@ async function initPlayground(containerId) {
733736
// Load WASM in background
734737
try {
735738
await initWasm();
736-
terminal.writeln(" \x1b[1;32mdone!\x1b[0m");
739+
const sizeStr = wasmSize > 0 ? ` (${(wasmSize / 1024 / 1024).toFixed(1)} MB)` : "";
740+
terminal.writeln(` \x1b[1;32mdone!\x1b[0m${sizeStr}`);
737741
terminal.writeln("");
738742
terminal.writeln("Type \x1b[1;32mhelp\x1b[0m for available commands.");
739743
terminal.writeln("Sample data files: names.txt, numbers.txt, fruits.txt, csv.txt, words.txt");

0 commit comments

Comments
 (0)