v157 · concept 2 · inspection / configuration

Download on a constrained device

On a phone, downloadable means Chrome would have to fetch the language-detection model over whatever connection the person has right now. This page reads the signals a mobile page can actually see (connection type, Save-Data, device memory, free storage, online state), combines them with availability() and recommends one of three actions: detect now, ask first, or wait. The download itself only starts when you press the button that says so.

1 · what this device reports

Where a signal isn't exposed (for example navigator.connection and deviceMemory are Chromium-only), the page says unknown and doesn't guess.

2 · decide

No decision yet. Nothing has been downloaded.

3 · download only when asked

This calls LanguageDetector.create({ monitor, signal }) inside your tap. If the model is downloadable, Chrome starts fetching it and reports downloadprogress events. Cancel aborts the AbortSignal.

Not started.

why this matters on Android

the code

const ac = new AbortController();
button.onclick = async () => {           // inside the tap: transient activation
  const detector = await LanguageDetector.create({
    signal: ac.signal,
    monitor: (m) => m.addEventListener("downloadprogress", (e) => progress.value = e.loaded),
  });
};
cancel.onclick = () => ac.abort();       // create() rejects with AbortError

see also