<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Madosuite]]></title><description><![CDATA[Madosuite]]></description><link>https://madosuite.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sat, 28 Nov 2026 00:42:26 GMT</lastBuildDate><atom:link href="https://madosuite.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[You Don't Need a Server for That: 7 File Jobs the Browser Does on Its Own]]></title><description><![CDATA[Most "free online tools" for files work the same way: you upload a contract, a passport scan or a family video, a server does the work, and you download…]]></description><link>https://madosuite.hashnode.dev/you-don-t-need-a-server-for-that-7-file-jobs-the-browser-does-on-its-own</link><guid isPermaLink="true">https://madosuite.hashnode.dev/you-don-t-need-a-server-for-that-7-file-jobs-the-browser-does-on-its-own</guid><category><![CDATA[webdev]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[WebAssembly]]></category><category><![CDATA[privacy]]></category><dc:creator><![CDATA[Kittizzp]]></dc:creator><pubDate>Thu, 26 Nov 2026 13:06:14 GMT</pubDate><content:encoded><![CDATA[<p>Most "free online tools" for files work the same way: you upload a contract, a passport scan or a family video, a server does the work, and you download the result. For a lot of these jobs the server isn't needed anymore. The browser you're reading this in can do them itself.</p>
<p>I build <strong><a href="https://madosuite.com">Madosuite</a></strong>, a free set of 356 file tools: merge, compress and convert PDFs, Word/Excel/PowerPoint to PDF and back, remove image backgrounds, compress video, OCR scans, open ZIP and RAR, make QR codes, and summarize PDFs with a model that runs on your own GPU. All of it runs in the browser, so files are never uploaded, and there's no sign-up and no daily limit.</p>
<p>Building it, I've hit most of the walls already. Below are seven file jobs you can do client-side, each with code you can paste and the catch I found when I ran it in Chrome, Safari and Firefox.</p>
<p>Every snippet was run in all three engines (Playwright: Chromium, WebKit, Firefox) before I put it here.</p>
<hr />
<h2>1. Shrink an image before it's uploaded</h2>
<p>No library needed. <code>createImageBitmap</code> decodes, <code>OffscreenCanvas</code> resizes and encodes.</p>
<pre><code class="language-js">async function compressImage(file, maxSide = 1600, quality = 0.8) {
  const bitmap = await createImageBitmap(file);
  const scale = Math.min(1, maxSide / Math.max(bitmap.width, bitmap.height));
  const canvas = new OffscreenCanvas(
    Math.round(bitmap.width * scale),
    Math.round(bitmap.height * scale)
  );
  canvas.getContext('2d').drawImage(bitmap, 0, 0, canvas.width, canvas.height);

  let blob = await canvas.convertToBlob({ type: 'image/webp', quality });
  if (blob.type !== 'image/webp') {
    // the browser can't write WebP and quietly gave you a PNG
    blob = await canvas.convertToBlob({ type: 'image/jpeg', quality });
  }
  return blob.size &lt; file.size ? blob : file; // never hand back something bigger
}
</code></pre>
<p><strong>The catch:</strong> ask for WebP and you don't always get WebP. On a 316 KB photo:</p>
<table>
<thead>
<tr>
<th>Engine</th>
<th>What came back</th>
</tr>
</thead>
<tbody><tr>
<td>Chromium</td>
<td>WebP, 245 KB</td>
</tr>
<tr>
<td>Firefox</td>
<td>WebP, 244 KB</td>
</tr>
<tr>
<td>WebKit (Safari)</td>
<td>not WebP, so JPEG: <strong>452 KB, bigger than the original</strong></td>
</tr>
</tbody></table>
<p>Check <code>blob.type</code>, and compare sizes before you replace the user's file. If you really need WebP in Safari, ship an encoder compiled to wasm (jSquash is a good one).</p>
<hr />
<h2>2. Merge PDFs</h2>
<p><a href="https://pdf-lib.js.org/">pdf-lib</a> copies pages between documents without re-rendering them, so text stays text.</p>
<pre><code class="language-js">import { PDFDocument } from 'pdf-lib';

async function mergePdfs(files) {
  const merged = await PDFDocument.create();
  for (const file of files) {
    const doc = await PDFDocument.load(await file.arrayBuffer());
    const pages = await merged.copyPages(doc, doc.getPageIndices());
    pages.forEach((page) =&gt; merged.addPage(page));
  }
  return new Blob([await merged.save()], { type: 'application/pdf' });
}
</code></pre>
<p><strong>The catch:</strong> password-protected PDFs throw on <code>load</code>. Catch that error and tell the user which file it was, instead of failing the whole merge. Also keep in mind the files are held in memory: fine for documents, not for 500 MB scans on a phone.</p>
<hr />
<h2>3. Compress a video</h2>
<p>WebCodecs gives the browser hardware video encoders. <a href="https://mediabunny.dev/">Mediabunny</a> wraps demuxing, encoding and muxing into a few lines:</p>
<pre><code class="language-js">import {
  Input, Output, Conversion, BlobSource, BufferTarget,
  Mp4OutputFormat, ALL_FORMATS, QUALITY_LOW,
} from 'mediabunny';

async function compressVideo(file) {
  const input = new Input({ source: new BlobSource(file), formats: ALL_FORMATS });
  const output = new Output({ format: new Mp4OutputFormat(), target: new BufferTarget() });
  const conversion = await Conversion.init({ input, output, video: { bitrate: QUALITY_LOW } });
  if (!conversion.isValid) throw new Error("This browser can't convert this file");
  await conversion.execute();
  const blob = new Blob([output.target.buffer], { type: 'video/mp4' });
  return blob.size &lt; file.size ? blob : file;
}
</code></pre>
<p><strong>The catch:</strong> the same code and the same 842 KB clip gave very different results:</p>
<table>
<thead>
<tr>
<th>Engine</th>
<th>Output</th>
</tr>
</thead>
<tbody><tr>
<td>Chromium</td>
<td>413 KB</td>
</tr>
<tr>
<td>WebKit</td>
<td>511 KB</td>
</tr>
<tr>
<td>Firefox</td>
<td><strong>4.66 MB, five times bigger</strong></td>
</tr>
</tbody></table>
<p>Encoders differ per browser and per OS. Always compare the size, and show the user what happened instead of silently handing back a bigger file.</p>
<hr />
<h2>4. Read text from a scan (OCR)</h2>
<p><a href="https://github.com/naptha/tesseract.js">tesseract.js</a> is Tesseract compiled to WebAssembly.</p>
<pre><code class="language-js">import { createWorker } from 'tesseract.js';

const worker = await createWorker('eng');
const { data } = await worker.recognize(file);
console.log(data.text);
await worker.terminate();
</code></pre>
<p><strong>The catch:</strong> the multi-threaded wasm build needs <code>SharedArrayBuffer</code>, which needs your page to be cross-origin isolated:</p>
<pre><code>Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp
</code></pre>
<p>Check <code>self.crossOriginIsolated</code> in the console. Then watch your CDN. Mine kept serving an old copy of a wasm file <strong>with its old headers</strong>, because the file's bytes (and so its URL) hadn't changed. OCR worked locally and broke only in production. The fix that stuck was to put a hash of the headers file into the folder name the wasm is served from, so a header change is also a URL change.</p>
<hr />
<h2>5. Run an image model on the user's GPU</h2>
<p><a href="https://onnxruntime.ai/docs/tutorials/web/">ONNX Runtime Web</a> runs ONNX models on WebGPU, falling back to WebAssembly. Background removal, upscaling and face detection all work this way.</p>
<pre><code class="language-js">import * as ort from 'onnxruntime-web/webgpu';

const session = await ort.InferenceSession.create(modelBytes, {
  executionProviders: ['webgpu', 'wasm'], // GPU if there is one, CPU otherwise
});
const input = new ort.Tensor('float32', pixels, [1, 3, 1024, 1024]);
const result = await session.run({ [session.inputNames[0]]: input });
</code></pre>
<p><strong>The catch:</strong> don't call <code>session.run()</code> again while a run is still going on the same WebGPU session. In my case both calls hung forever, with no error and nothing in the console. It's easy to trigger: a user presses the button twice. Queue the runs:</p>
<pre><code class="language-js">let lane = Promise.resolve();

function runModel(feeds) {
  const job = lane.then(() =&gt; session.run(feeds));
  lane = job.catch(() =&gt; {}); // a failed run must not block the next one
  return job;
}
</code></pre>
<p>With the queue, a double press finished both runs in under 9 seconds. Without it, the page was still on "Working…" after 500 seconds.</p>
<hr />
<h2>6. Download big models without Safari giving up</h2>
<p>Models are big: background removal is tens of MB, a small language model is gigabytes. One <code>fetch</code> of a large file worked in Chrome and failed part-way in Safari with a bare <code>TypeError: Load failed</code>. Fetching several large files at once in Safari failed every time.</p>
<p>What works: cut the model into 8 MiB parts at build time, then fetch the parts <strong>one at a time</strong> into one preallocated buffer, retrying only the part that broke:</p>
<pre><code class="language-js">async function fetchParts(parts, totalSize) {
  const all = new Uint8Array(totalSize); // one buffer: no 2x memory spike when joining
  let at = 0;
  for (const url of parts) {
    const start = at;
    for (let attempt = 1; ; attempt++) {
      try {
        const res = await fetch(url);
        if (!res.ok) throw Object.assign(new Error(`HTTP ${res.status}`), { status: res.status });
        const reader = res.body.getReader();
        for (;;) {
          const { done, value } = await reader.read();
          if (done) break;
          all.set(value, at);
          at += value.length;
        }
        break;
      } catch (err) {
        at = start; // drop the broken part, keep the rest
        if (attempt === 4 || (err.status &gt;= 400 &amp;&amp; err.status &lt; 500)) throw err;
        await new Promise((r) =&gt; setTimeout(r, 400 * attempt));
      }
    }
  }
  return all;
}
</code></pre>
<p>With this, a 3.35 GB model (400 parts) comes down in Safari in about 2 minutes 17 seconds on my connection, without a single failed download.</p>
<hr />
<h2>7. Run a small language model, and don't trust it</h2>
<p><a href="https://github.com/ngxson/wllama">wllama</a> is llama.cpp in the browser, with WebGPU support. It takes any GGUF model:</p>
<pre><code class="language-js">import { Wllama } from '@wllama/wllama';

const wllama = new Wllama({ default: wasmUrl });
await wllama.loadModel([modelBlob], { n_ctx: 4096, n_gpu_layers: 999 });

const stream = await wllama.createChatCompletion({
  messages: [{ role: 'user', content: `Summarize:\n\n${text}` }],
  max_tokens: 400,
  temperature: 0,
  stream: true,
});
let out = '';
for await (const chunk of stream) out += chunk.choices[0]?.delta?.content ?? '';
</code></pre>
<p><strong>The catch:</strong> small models make things up, and how often depends a lot on the model. I gave three of them the same 45 summaries to write (15 languages, 3 documents each), then read every output and counted the ones with a factual mistake:</p>
<table>
<thead>
<tr>
<th>Model</th>
<th>Summaries with a mistake</th>
</tr>
</thead>
<tbody><tr>
<td>Gemma 4 E2B (q4_0)</td>
<td>6 / 45</td>
</tr>
<tr>
<td>Qwen3.5 2B (q4)</td>
<td>29 / 45</td>
</tr>
<tr>
<td>Qwen3.5 0.8B (q8)</td>
<td>32 / 45</td>
</tr>
</tbody></table>
<p>Even the best one was wrong in about 1 of 8. So design for it:</p>
<ul>
<li>Show the model's text <strong>next to</strong> the source, never instead of it.</li>
<li>Drop any sentence with a number or a name that isn't in the source document. A few lines of code catch most invented facts.</li>
<li>Only offer the feature where it fits. Gemma 4 E2B needed about 3.8 GB of GPU memory, which rules out phones. Offer it when the model needs at most half of <code>navigator.deviceMemory</code>.</li>
</ul>
<hr />
<h2>Saving the result</h2>
<p>The last step needs no server either:</p>
<pre><code class="language-js">function save(blob, name) {
  const url = URL.createObjectURL(blob);
  const a = Object.assign(document.createElement('a'), { href: url, download: name });
  a.click();
  setTimeout(() =&gt; URL.revokeObjectURL(url), 10_000);
}
</code></pre>
<hr />
<h2>So, is client-side ready?</h2>
<p>For most everyday file jobs, yes: images, PDFs, OCR, short videos and archives all run fine on a normal laptop. The limits are real, though:</p>
<ul>
<li><strong>Memory.</strong> Everything happens in the user's RAM. A phone will refuse things a server wouldn't.</li>
<li><strong>First load.</strong> Models and wasm builds are megabytes to gigabytes. Cache them well, and say up front how big a download is.</li>
<li><strong>Browser differences.</strong> Same API, different results (see sections 1 and 3). Test all three engines, not just the one you develop in.</li>
</ul>
<p>In return you get no upload wait, no server bill per file, and a privacy story the user can check: open DevTools, Network tab, and run the tool.</p>
<p>If you'd rather use finished tools than build them, every job above is on <a href="https://madosuite.com">Madosuite</a>, free and with nothing uploaded.</p>
<p>What file job are you still sending to a server? Tell me in the comments. If it's doable in the browser, I'll try it.</p>
]]></content:encoded></item></channel></rss>