GO-Ve01
ServicesDevelopersBooksDictionaryPapersWikidataEncyclopediaSearchBabelCareersDeck

PerformanceResourceTiming: contentEncoding property

Performance API

Performance API

The **`contentEncoding`** read-only property of the PerformanceResourceTiming interface is a string indicating the content encoding of the fetched resource.

The content type is extracted from the Content-Encoding HTTP header sent in the resource's fetch response.

## Value

A string indicating the content-encoding of the content.
This may be one of the following values:

- `gzip`
- : A format using the [Lempel-Ziv coding](https://en.wikipedia.org/wiki/LZ77_and_LZ78#LZ77) (LZ77), with a 32-bit CRC.
This is the original format of the UNIX _gzip_ program.
The HTTP/1.1 standard also recommends that the servers supporting this content-encoding should recognize `x-gzip` as an alias, for compatibility purposes.
- `compress`
- : A format using the [Lempel-Ziv-Welch](https://en.wikipedia.org/wiki/LZW) (LZW) algorithm.
The value name was taken from the UNIX _compress_ program, which implemented this algorithm.
Like the compress program, which has disappeared from most UNIX distributions, this content-encoding is not used by many browsers today, partly because of a patent issue (it expired in 2003).
- `deflate`
- : Using the [zlib](https://en.wikipedia.org/wiki/Zlib) structure (defined in 1950) with the [deflate](https://en.wikipedia.org/wiki/Deflate) compression algorithm (defined in 1951).
- `br`
- : A format using the Brotli algorithm structure (defined in 7932).
- `zstd`
- : A format using the Zstandard algorithm structure (defined in 8878).
- `dcb`
- : A format that uses the [Dictionary-Compressed Brotli algorithm](https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-compression-dictionary#name-dictionary-compressed-brotl). See [Compression Dictionary Transport](/docs/Web/HTTP/Guides/Compression_dictionary_transport).
- `dcz`
- : A format that uses the [Dictionary-Compressed Zstandard algorithm](https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-compression-dictionary#name-dictionary-compressed-zstan). See [Compression Dictionary Transport](/docs/Web/HTTP/Guides/Compression_dictionary_transport).

## Examples

### Filtering resources

The `contentEncoding` property can be used to get specific resource timing entries only; for example, only those related to [Compression Dictionary Transport](/docs/Web/HTTP/Guides/Compression_dictionary_transport).

The following example uses a PerformanceObserver to notify of new `resource` performance entries as they are recorded in the browser's performance timeline.
The `buffered` option is used for accessing entries from before the observer creation.

```js
const observer = new PerformanceObserver((list) => {
const dictionaryCompressedResources = list
.getEntries()
.filter(
(entry) =>
entry.contentEncoding === "dcb" || entry.contentEncoding === "dcz",
);
console.log(dictionaryCompressedResources);
});

observer.observe({ type: "resource", buffered: true });
```

The following example uses Performance.getEntriesByType(), which only shows `resource` performance entries present in the browser's performance timeline at the time you call the method.

```js
const dictionaryCompressedResources = performance
.getEntriesByType("resource")
.filter(
(entry) =>
entry.contentEncoding === "dcb" || entry.contentEncoding === "dcz",
);
console.log(dictionaryCompressedResources);
```

## Specifications

## Browser compatibility

source: MDN Web Docs mirror · page

Cite this

"PerformanceResourceTiming: contentEncoding property". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/contentEncoding

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·