# Optimize PDF loading with linearized documents

Linearized PDFs allow viewing a PDF while it’s still downloading, enabling faster access to information in the PDF. This is especially useful for large documents where quick access is critical.

Document Engine with [streaming](https://www.nutrient.io/guides/document-engine/viewer/streaming.md) offers even more advantages, but sometimes linearized downloading is the best option.

## Comparison

|                                       | Document Engine streaming                                                             | Linearized downloading                                                                |
| ------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
| Fast initial page rendering           |  |  |
| Only requires HTTPS server            |     |  |
| Read-write while downloading          |  |     |
| Only downloads the required data      |  |     |
| Any PDF supported without preparation |  |     |

## Enable linearized downloading

PDFs are read-only until fully downloaded. This means that while you can see the information in a PDF, you cannot, for example, add an annotation until the PDF is fully downloaded.

1. **Prepare your PDF for linearization**: This can be done using Nutrient’s [Document Engine](https://www.nutrient.io/guides/document-engine/optimization/linearize.md) or [.NET SDK](https://www.nutrient.io/guides/dotnet/optimization/linearize.md). If you’re using other third-party tools, PDF linearization might be called fast web loading.

2. **Upload the linearized PDF** to your HTTPS server.

3. **Load the document in `NutrientViewer.load`**. [`allowLinearizedLoading`](https://www.nutrient.io/api/web/interfaces/Configuration.html#allowlinearizedloading) is enabled by default, so no extra configuration is required:

```js

NutrientViewer.load({
  container: "#container",

  document: "https://example.com/path/to/linearized.pdf",
});

```

If you need to disable linearized downloading, set `allowLinearizedLoading: false`.

## Check server support

Use curl to check if your server accepts range requests:

```bash

curl -I https://example.com/path/to/linearized.pdf -H "Range: bytes=0-1"

```

If the server supports range requests, you’ll see a `206 Partial Content` response and an `Accept-Ranges: bytes` header.

The HEAD request above may fail on some servers depending on how they handle requests. For example, S3 presigned URLs are HTTP verb-specific, so a URL signed for GET requests will reject HEAD requests. If the HEAD request fails, try using a GET request instead:

```bash

curl -r 0-1 https://example.com/path/to/linearized.pdf -o /dev/null -w "%{http_code}\n"

```

This sends a GET request with a `Range` header. A `206` response indicates the server supports range requests.

You might notice that very small linearized PDFs are downloaded in a single request, even when your server is correctly configured for range requests and responds with a `206 Partial Content` status.

This is expected behavior and is due to a performance optimization in the viewer.

- The viewer is designed to request a minimum initial block of data (a “chunk”) of approximately ~128 KB. This size is optimized to render the first page of most documents quickly.

- If your PDF file is smaller than this ~128 KB threshold, the viewer’s initial request will cover the entire file, resulting in a single download.

## Additional information

- This is strictly a feature to speed up viewing a PDF while downloading. It won’t allow you to modify the PDF until it’s fully downloaded.

- Linearized downloading only has an effect when a PDF is downloaded from an external web server.

- When using Nutrient Web SDK in the browser, temporary download storage is also managed automatically. For larger eligible PDFs, it may use the browser’s [origin private file system (OPFS)](https://developer.mozilla.org/en-US/docs/Web/API/File_System_API/Origin_private_file_system) to reduce peak browser RAM usage while the document downloads. If you want to disable that behavior, set [`tempStorage: "memory"`](https://www.nutrient.io/api/web/interfaces/Configuration.html#tempstorage). For more information, refer to the [temporary storage](https://www.nutrient.io/guides/web/open-a-document/temp-storage.md) guide.
---

## Related pages

- [PDF annotation diffs in our JavaScript viewer](/guides/web/performance/annotation-diff.md)
- [Enhance PDF performance with document streaming](/guides/web/performance/streaming.md)
- [Optimizing performance in the Nutrient JavaScript PDF viewer](/guides/web/best-practices/performance.md)
- [Web caching for our JavaScript PDF viewer](/guides/web/best-practices/caching-on-the-web.md)

