A small PDF is usually easy to handle in a browser.

Select a file, load it into a JavaScript library, perform an operation and download the result. For a document with a few pages, this workflow can feel almost effortless.

Then someone opens a 250 MB scanned PDF.

Suddenly, the browser tab starts consuming memory, the interface becomes unresponsive and the operation takes much longer than expected.

This is one of the less glamorous problems of building browser-based file tools.

File size isn't the whole story

A PDF's file size doesn't tell you everything about how difficult it will be to process.

A document containing mostly text can be relatively small. A scanned document might contain hundreds of full-page images.

Those two files can behave very differently.

Consider three operations:

Merging PDFs mostly involves reading document structures and copying pages.

Rendering pages into previews requires decoding and drawing their contents.

OCR involves additional image processing and text recognition.

The third operation can be particularly demanding because image resolution, page dimensions and recognition models all affect resource consumption.

A useful file-processing interface should account for the operation being performed, not just the number displayed next to the filename.

Browser memory needs attention

JavaScript applications can accidentally hold multiple copies of the same data.

For example, an application might keep the original File object, read the file into an ArrayBuffer, create additional processing buffers and retain rendered previews.

Some libraries also allocate temporary memory internally.

The result is that a relatively ordinary document can require substantially more memory than its original size.

A few practical improvements help:

Avoid reading files repeatedly when an existing buffer can be reused.

Release references to temporary objects when they're no longer needed.

Generate previews only when necessary.

Avoid rendering every page simultaneously.

Consider Web Workers for CPU-heavy operations that would otherwise block the interface.

Web Workers don't magically reduce memory consumption, but they can keep expensive processing away from the main UI thread.

For operations that support streaming or incremental processing, those approaches are also worth considering.

Give users useful feedback

One particularly frustrating experience is clicking a button and seeing absolutely nothing happen.

The application might be working, but the user has no way to tell.

Progress indicators help, although they need to represent actual progress rather than simply displaying a spinning animation.

If an operation has identifiable stages, show them separately.

For example:

Reading input files.

Preparing document data.

Processing pages.

Generating the output.

Preparing the download.

It's also worth handling failures explicitly. A browser can run out of memory, a file can be malformed, and a library can reject an unsupported feature.

An honest error message is better than leaving someone staring at an inactive button.

A practical approach to browser file tools

While building Pocket PDF, I've been working with these kinds of trade-offs across PDF, image, audio, video and text utilities.

The idea is to let people process files directly in their browsers without creating an account, installing software or uploading files to a processing server.

That doesn't mean every operation works equally well on every device. Browser memory, file formats and hardware still matter.

It means the architecture should respect those limitations instead of pretending they don't exist.

You can explore the project at https://www.pocketpdf.site.

For developers working with browser-side file processing, I'm curious about one thing: how do you decide when an operation should run in the main thread, a Web Worker or a separate processing environment?