When working on a Wix site with code, it's important to understand how duplication and deletion affect a site's functionality. Whether you're copying an entire site, a page, or an individual element, or deleting elements with connected code, the outcome depends on how you structure and wire your code.
You can duplicate sites and pages, as well as clone and transfer your Wix sites. Whether you're duplicating a single page, an entire site, or cloning or transferring a site, the new version maintains the code and events.
If a site uses the Secrets Manager to store sensitive information like API keys or tokens, be aware that secrets behave differently during site operations:
When you copy and paste an element that has associated code, the system duplicates the element itself, but doesn't include any events, wiring, or code linked to it.
Important: If you're building a Wix site that others can edit, make sure they understand the implications of changing elements that have associated code. For more information, see Working with Collaborators.
When you delete elements from a site, the behavior of any associated code depends on the type of event handler used. For both static and dynamic frontend event handlers, the code itself isn't automatically removed, but how it's connected to the element changes.
Note: In the editor, if a collaborator tries to delete elements referenced by code, a confirmation prompt displays. The prompt helps prevent accidental deletions that can impact your code. The prompt displays for:
icon displays for these elements as an indicator.When you delete an element with a dynamic event handler, the associated code isn't removed. If you add a new element and give it the same ID as the deleted one, the existing code continues to work as expected.
When you delete an element with static event handler, the associated code remains, but the system removes the event wiring. Because you can no longer wire static events, this means that the event handler no longer works. If you want to continue to use the event handler code, you need to change the code to use a dynamic event handler registered to an existing element.