# Widget JavaScript API

Open, close, toggle or remove the widget from your own code with window.Feedzzie.

When the widget has loaded, it adds four methods to `window.Feedzzie`:

| Method | What it does |
|---|---|
| `Feedzzie.open()` | Opens the panel |
| `Feedzzie.close()` | Closes the panel |
| `Feedzzie.toggle()` | Opens the panel if it is closed, and closes it if it is open |
| `Feedzzie.destroy()` | Removes the button and the panel from the page |

The widget loads after the page, so the methods exist only once it is ready. Check before you call them:

```js
if (window.Feedzzie && typeof window.Feedzzie.open === 'function') {
  window.Feedzzie.open()
}
```

## Open the panel from your own button

```html
<button type="button" onclick="window.Feedzzie && window.Feedzzie.open && window.Feedzzie.open()">
  Share feedback
</button>
```

The floating button stays on the page as well.

## Remove the widget

`Feedzzie.destroy()` removes the button and the panel. To show the widget again, reload the page.
