# Linearization

## Content

Linearized PDF documents allow the first page of a PDF to be displayed before the entire document is loaded. This behavior, also known as “fast web view,” improves PDF viewing performance in web browsers.
In DsPdfJS, PDF documents can be saved in linearized mode by specifying the saveMode option with the value SaveMode.Linearized. Linearization and incremental update modes are mutually exclusive and can't be used together.
For information about loading and saving PDF documents, see [Create and Save](https://developer.mescius.com/document-solutions/javascript-pdf-api/docs/features/create-and-save).

## Save a Linearized PDF

You can save a PDF document in linearized mode by specifying [SaveMode.Linearized](/document-solutions/javascript-pdf-api/api/enumerations/SaveMode#linearized) in the saveMode option of the savePdf method.
The following code example shows how to save a PDF document as a linearized PDF.

>type=note
> **Note:** The examples on this page use helper functions from the [Snippet Helpers](https://developer.mescius.com/document-solutions/javascript-pdf-api/docs/snippet-helpers) module. These utilities are provided only to simplify the examples and are not part of the DsPdfJS API.

```javascript
// load existing PDF
const inputDocData = await Util.loadFile("Wetlands.pdf");
const doc = PdfDocument.load(inputDocData);

// save the document in linearized mode
const docData = doc.savePdf({ saveMode: SaveMode.Linearized });

Util.saveFile("LinearizedPDF.pdf", docData);
```

## Get Linearized State

You can determine whether a PDF document is linearized using the [linearized](/document-solutions/javascript-pdf-api/api/classes/PdfDocument#linearized) accessor of the PdfDocument class.
The following code example shows how to retrieve the linearization state of a PDF document:

```auto
// load existing PDF
const inputDocData = await Util.loadFile("Wetlands.pdf");
const doc = PdfDocument.load(inputDocData);

// get linearized state
console.log(`Linearized: ${doc.linearized}`);
```