# Page Visibility API

## Overview

Page Visibility API allows web apps to know whether it is visible to the user or not.

It is especially useful for saving resources and improving performance by letting the app avoid performing unnecessary tasks when it is not visible.

## Demo

<https://nectar.website/demo/web-apis/page-visibility/>

## Usage

You can refer to the code present in `/partials/web-apis/page-visibility.html` file and use it accordingly.

## Reference

<https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://pmsgz.gitbook.io/nectar/advanced/web-apis/page-visibility.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
