---
url: /cookbook/modify-after-creation.md
description: >-
  Modify element properties immediately after creation in the editor by
  listening to the wpce_before_insert_node event.
---

# Modify an Element after Creation&#x20;

To modify an element right after it has been created (i.e. not after it has been duplicated or pasted from somewhere), you can listen for the `wpce_before_insert_node` event on the `document`. It triggers after an element is picked in the "Add Element" dialog.

```js
document.addEventListener('wpce_before_insert_node', event => {
  // Get the document node and the WPCE instance
  const { node, instance } = event.detail

  // Do something to the node, e.g. add children or modify properties
})
```
