---
title: onReady function
description: "``` Experimental customizations are not included by default and are extended to the plugin. Please use with caution and proper consent. ``` --- ## Case: Trigger custom function or action when viewer has finished loading the document and required files…"
url: "https://dearpdf.com/docs/onready-function/"
updated: "2022-09-04"
category: Advanced
---

# onReady function

```
Experimental customizations are not included by default and are extended to the plugin. Please use with caution and proper consent.
```

---

## Case:

Trigger custom function or action when viewer has finished loading the document and required files for displaying the PDF.

## Demo:

## Process:

We use `onReady` function to detect the viewer state. These are added to DEARPDF.defaults variable so that every flipbook on the page uses the customization.

```
<script>
    jQuery(function(){
        DEARPDF.defaults.onReady = function(app){
            alert("Viewer Ready");
            console.log(app);
        };
    });
</script>
```

```
For WordPress, please read on
How to add Custom Code to WordPress Pages
```
