# Write a plugin
A docsify plugin is a function with the ability to execute custom JavaScript code at various stages of Docsify's lifecycle.
## Setup
Docsify plugins can be added directly to the `plugins` array:
```js
window.$docsify = {
plugins: [
function myPlugin1(hook, vm) {
// ...
},
function myPlugin2(hook, vm) {
// ...
},
],
};
```
Alternatively, a plugin can be stored in a separate file and "installed" using a standard `
```
## Template
Below is a plugin template with placeholders for all available lifecycle hooks.
1. Copy the template
1. Modify the `myPlugin` name as appropriate
1. Add your plugin logic
1. Remove unused lifecycle hooks
1. Save the file as `docsify-plugin-[name].js`
1. Load your plugin using a standard `